1布局界面
首先导入XTabLayout依赖
implementation 'com.androidkun:XTabLayout:1.1.4'
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:background="@color/purple_primary"
tools:context=".activity.TabActivity">
<com.androidkun.xtablayout.XTabLayout
android:layout_marginTop="@dimen/dp_10"
android:id="@+id/tabLayout"
app:xTabMaxWidth="@dimen/dp_80"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_62"
app:xTabMode="scrollable"
app:xTabSelectedTextColor="@color/orange"
app:xTabTextColor="@color/colorWhite"
app:xTabTextSize="13sp"
android:layout_marginBottom="@dimen/dp_10"
app:xTabSelectedTextSize="15sp"/>
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
2 Activity界面
private XTabLayout tabLayout;
private ViewPager viewPager;
private TextView textView;
private List<Fragment> fragmentList = new ArrayList<>();//fragment列表
private List<String> stringList = new ArrayLi

本文介绍了如何在Android应用中仿照淘宝淘抢购的导航栏Tablayout进行自定义开发。首先,你需要导入XTabLayout依赖。然后,在Activity界面中设置假数据,并创建Fragment的适配器。接着,详细展示了item_headerone的XML布局设计,以实现所需的功能和视觉效果。
最低0.47元/天 解锁文章

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



