Questions tagged [android-tablayout]

Android TabLayout provides a layout to organize pages of information.

TabLayout provides a horizontal layout to display tabs.

Population of the tabs to display is done through TabLayout.Tab instances. You create tabs via newTab(). From there you can change the tab's label or icon via setText(int) and setIcon(int) respectively. To display the tab, you need to add it to the layout via one of the addTab(Tab) methods.

Useful links

2044 questions
307
votes
29 answers

TabLayout tab selection

How should I select a tab in TabLayout programmatically? TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager);
244
votes
13 answers

Tab not taking full width on Tablet device [Using android.support.design.widget.TabLayout]

I have setup tabs as UPDATE 29/05/2015 this post. Tabs take full width on my Nexus 4 mobile but on nexus 7 tablet it in center and not cover full screen width. Nexus 7 screenshot Nexus 4 screenshot
Max
  • 5,733
  • 4
  • 30
  • 44
184
votes
10 answers

How do you create an Android View Pager with a dots indicator?

Probably many of you (as me), have problem with creating ViewPager with bottom dots, like this: How do you create such an Android ViewPager?
RediOne1
  • 10,389
  • 6
  • 25
  • 46
144
votes
13 answers

How do I change a tab background color when using TabLayout?

This is my code in the main activity public class FilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_filter); …
Joel Lara
  • 1,541
  • 2
  • 10
  • 7
138
votes
21 answers

Change the font of tab text in android design support TabLayout

I'm trying to work on the new TabLayout from the android design library. I want to change tab text to custom font. And,I tried to search some styling related to TabLayout,but ended up to this. Please guide how can I change the tab text fonts.
Dory
  • 7,462
  • 7
  • 33
  • 55
129
votes
11 answers

Text size of android design TabLayout tabs

I have difficulties changing the text size of the tabs of design library tablayout (android.support.design.widget.TabLayout). I managed to change it by assigning tabTextAppearance in TabLayout…
Malko
  • 1,336
  • 2
  • 8
  • 5
111
votes
18 answers

android:textAllCaps="false" not working for TabLayout design Support

I have set android:textAllCaps="false" in my android.support.design.widget.TabLayout thought it is showing the Tab Title in All caps only. How can I remove all caps?
102
votes
12 answers

How to use TabLayout with ViewPager2 in Android

I want to use com.google.android.material.tabs.TabLayout component with Android's new ViewPager implementation androidx.viewpager2.widget.ViewPager2. However, the setupWithViewPager(..) method provided by TabLayout supports only the old ViewPager…
100
votes
19 answers

How do I change the color of icon of the selected tab of TabLayout?

I'm using a TabLayout with a ViewPager and I'm wondering how I can most efficiently change the color of the icon of the selected tab in the TabLayout. A perfect reference for how this is implemented is Google's Youtube app. On the main page, there…
waylonion
  • 6,866
  • 8
  • 51
  • 92
81
votes
5 answers

TabLayout tabs text not displaying

I am using TabLayout inside a Fragment to display three fixed tabs and the tabs are working but it doesn't show the tab text even after I set the app:tabTextColor attribute in the layout it's still not visible. NewFragment.java public class…
Jacques Krause
  • 5,523
  • 9
  • 27
  • 43
74
votes
2 answers

TabLayout without using ViewPager

I want to implement a TabLayout because it is simple but all the tutorials I have found involve a ViewPager. I just want something like OnClickListener where if I click the Add icon, it will show a toast that displays "tab 1" and if I click a…
Eleojasmil J Milagrosa
  • 1,944
  • 1
  • 13
  • 15
73
votes
9 answers

How to change selected Tab Text color using TabLayout from code in Android?

I'm using android.support.widget.TabLayout to make a Tab view, and I want to change the selected tabs text color from code (not from xml or by styling). How can I do this ?
rastha67
  • 851
  • 1
  • 6
  • 13
70
votes
13 answers

Tablayout with icons only

I am using design support to create tabs. I am also using ViewPager for swipable tabs. Now, I don't know how to use only icons instead of texts in tabs. I tried finding out but didn't get any success. My code: Toolbar toolbar; private TabLayout…
androGuy
  • 855
  • 2
  • 8
  • 11
61
votes
19 answers

TabLayout not filling width when tabMode set to 'scrollable'

I have added TabLayout (from support library v22.2.1) to my Fragment as:
Sufian
  • 6,405
  • 16
  • 66
  • 120
57
votes
13 answers

Disable TabLayout

I'm using the new class provided by the design library : TabLayout. And I want in specific cases that the one I'm using can't change tab anymore. I manage to disable swipe on its viewpager but I can't figure out how to disable the change of page by…
MHogge
  • 5,408
  • 15
  • 61
  • 104
1
2 3
99 100