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代码中操作

在onCreate()方法中初始化这3个方法
private void initView() {
mMagi

本文介绍了如何在 Android 应用中使用 MagicIndicator 控件,作为 TabLayout 的替代品。首先,你需要在 APP 的 build.gradle 文件中导入依赖并同步。接着,在 XML 布局文件中添加 MagicIndicator 控件,并在 Java 代码的 onCreate() 方法中进行初始化配置。通过这些步骤,你可以实现一个功能丰富的指示器与 ViewPager 结合的用户界面。
最低0.47元/天 解锁文章
626

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



