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

A “simpler” answer borrowed from Kaizie would just be adding app:tabMaxWidth=”0dp” in your TabLayout xml: <android.support.design.widget.TabLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” app:tabMaxWidth=”0dp” app:tabGravity=”fill” app:tabMode=”fixed” />

Changing the background color of a Tab in TabLayout (Android design support library) doesn’t occupy the entire tab space

Define a selector as a drawable, and also have a drawable for the selected/unselected states. For this solution, I started with the code from this answer, and then added the functionality that changes the background color for the current Tab. First, the selector, tab_background.xml in the drawable folder: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:drawable=”@drawable/tab_background_selected” … Read more

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

What finally worked for me is similar to what @如果我是DJ suggested, but the tabBackground should be in the layout file and not inside the style, so it looks like: res/layout/somefile.xml: <android.support.design.widget.TabLayout …. app:tabBackground=”@drawable/tab_color_selector” … /> and the selector res/drawable/tab_color_selector.xml: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:drawable=”@color/tab_background_selected” android:state_selected=”true”/> <item android:drawable=”@color/tab_background_unselected”/> </selector>

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

All we need are: ViewPager, TabLayout and 2 drawables for selected and default dots. Firstly, we have to add TabLayout to our screen layout, and connect it with ViewPager. We can do this in two ways: Nested TabLayout in ViewPager <androidx.viewpager.widget.ViewPager android:id=”@+id/photos_viewpager” android:layout_width=”match_parent” android:layout_height=”match_parent”> <com.google.android.material.tabs.TabLayout android:layout_width=”match_parent” android:layout_height=”wrap_content”/> </androidx.viewpager.widget.ViewPager> In this case TabLayout will be automatically … Read more