MagicIndicator指示器 是新版studio中的控件,替代原来的Tablayout,功能是一样的。
使用方法:
1、导依赖 在APP gradle中添加
//指示器 implementation 'com.github.hackware1993:MagicIndicator:1.5.0'
在项目中添加如图指示器依赖
添加完同步一下。
2、在xml中添加控件
<net.lucode.hackware.magicindicator.MagicIndicator android:id="@+id/mid" android:layout_width="match_parent" android:layout_height="50dp" android:background="#d43d3d" />
<androidx.viewpager.widget.ViewPager android:id="@+id/vp_chengdan" android:layout_width="match_parent" android:layout_height="match_parent" />
3、在java代码中操作