TabLayout常规使用
Android原生TabLayout使用的超全解析(看这篇就够了) - 爱码帮™分享编程知识和开发经验
1、xml布局
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/common_dp_40"
app:tabBackground="@null"
app:tabGravity="center"
app:tabIndicatorColor="@color/colorAccent"
app:tabIndicatorHeight="@dimen/common_dp_0"
app:tabMaxWidth="@dimen/common_dp_200"
app:tabMinWidth="@dimen/common_dp_20"
app:tabMode="scrollable"
app:tabPaddingEnd="@dimen/common_dp_15"
app:tabPaddingStart="@dimen/common_dp_12"
app:tabSelectedTextColor="@color/common_white"
app:tabTextAppearance="@style/CommonTabLayoutTextStyle"
app:tabTextColor="@color/common_white" />
<android.support.v4.view.ViewPager
android:id="@+id/vpContent"
android:layout_width="match_parent"
android:layout_height="@dimen/common_dp_0"
android:layout_marginTop="@dimen/common_dp_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLimitTime" />
</LinearLayout>
CommonTabLayoutTextStyle.xml<

本文详细介绍了Android中TabLayout组件的使用方法,包括XML布局配置、FragmentPagerAdapter实现、初始化步骤及Tab切换监听等。同时提供了自定义TabLayout布局的方式。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



