如何适应Android中的标签宽度屏幕 [英] How to fit the tab width screen in android
本文介绍了如何适应Android中的标签宽度屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用android支持库实现标签布局,看起来像
I implement the tab layout using android support library and it looks like
此处标签页的宽度与屏幕不匹配,并且我的布局为
Here the tab width is not fit with screen and my layout is
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white" />
</LinearLayout>
推荐答案
尝试在您的TabLayout
上调用这些方法:
Try calling those methods on your TabLayout
:
tabLayout.setTabMode(TabLayout.MODE_FIXED);
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
这篇关于如何适应Android中的标签宽度屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文