问题
I have created a view pager with TabLayout. Now the issue is if I have 2 or more tabs then everything is fine. But if I am having only one tab then it is not covering the entire screen width. PFA the xml layout
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed"
style="@style/TabLayout"
android:fillViewport="true"
android:layout_below="@id/ssrToolbar"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/sliding_tabs"
android:layout_above="@+id/llButtonLayout"
android:background="@android:color/white" />
Also here are the two images
回答1:
If someones still interested you should add this property for TabLayout in xml app:tabMaxWidth="big_number"
, for big_number i chose 2000dp. If you are not assigning any value default implementation subtracts widths measured specifications size with TAB_MIN_WIDTH_MARGIN
value.
来源:https://stackoverflow.com/questions/33874385/single-tab-in-tablayout-is-not-covering-the-entire-width