【发布时间】:2016-11-26 10:42:38
【问题描述】:
我要为我的TabLayout 实现滚动功能。它滚动成功,但选项卡重力根本不起作用。我的选项卡与视图的右侧对齐。我想在中心位置显示这些标签,或者至少填充 layout_width。
我在下面添加了我的代码。请提出使事情正常进行的可能方法。
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways|snap"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
app:tabMode="scrollable"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
这是标签布局的屏幕截图。
【问题讨论】:
-
@prakash android:layout_gravity="center_horizontal" 和 app:tabGravity="fill" 都不适合我。我看到了你提供的链接。