I am creating an application which uses Tab Layout. The requirement of the app is that there should be many tabs. Making 4-5 tabs on the tab bar was ok. But when more tham 5 tabs are added, it gets very compressed. Is there a way in android where i can have many tabs and not make it look compressed? maybe some what like having a "More" button on the tab or having horizontal scrollable tabs?
I forgot to mention this earlier that it should work on android 2.2(api 8)
Thanks
If you want to add Android tabs without sliding, then replace the layout with the fragment on tab selected listener event. And, if you want to add sliding tabs, then use ViewPager. In this Android tablayout example, we'll see how to create tabs in android studio with sliding using ViewPager.
This example demonstrates how do I create a Tab Layout in android app. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 3 − Add the following code to res/layout/activity_main. xml.
For tab layout add the line
app:tabMode="scrollable"
to your Xml file eg
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabTextColor="@color/colorWhite"
app:tabSelectedTextColor="@color/colorSecondary"
android:background="@color/colorPrimary"
app:tabIndicatorColor="@color/colorSecondary"
app:tabIndicatorHeight="5dp"/>
</android.support.design.widget.AppBarLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With