Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different tabMode for TabLayout

I`m using ViewPager and TabLayout. If tabs can be placed on the display tabMode they must be:

app:tabMode="fixed"

else

app:tabMode="scrollable"

How can I do this?

like image 570
Tiberal Avatar asked Jul 02 '15 17:07

Tiberal


People also ask

Can I use TabLayout without ViewPager?

These methods have a features: always attaching the "tab widget" with a ViewPager , and in order to make this requirement, we must disable swipe feature of the ViewPager . Now, with Material design, we now use TabLayout widget, which can "stand alone" to build a tab bar and do not need a ViewPager anymore.


2 Answers

I din't get your question but i may help you, if tabs count is static or fixed(you know number of tabs) then app:tabMode="fixed" if tabs count is dynamic(data coming from feed) then app:tabMode="scrollable"

like image 156
Ram Prakash Bhat Avatar answered Sep 24 '22 11:09

Ram Prakash Bhat


There are two tabModes we can use with TabLayout:

app:tabMode="fixed"
app:tabMode="scrollable"

and programatically it is like

 tabLayout.setTabMode(TabLayout. MODE_FIXED);
tabLayout.setTabMode(TabLayout. MODE_SCROLLABLE);

above is same for MODE_SCROLLABLE

to understand TabLayout modes you can refer below Link https://developer.android.com/reference/android/support/design/widget/TabLayout

like image 45
Yashoda Bane Avatar answered Sep 23 '22 11:09

Yashoda Bane