1169927533 / YPKTabDemo

一个自定义tablayout View

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

远程依赖

Add it in your root build.gradle at the end of repositories:

allprojects {

	repositories {
		...
		maven { url 'https://jitpack.io' }
	}

}

Add the dependency

dependencies {

	  implementation 'com.github.dacaoyuan:YPKTabDemo:1.0.2'

}

使用方法

一:在xml布局中添加:

 <com.ypk.library.view.YPKTabLayoutView
        android:id="@+id/mYPKTabLayoutView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        app:arcControlX="30"
        app:tabTextColor="#fff"
        app:tabTextSize="15sp"
        app:view_bg_corners="0dp" />

二:activity中:


val tabTextList: MutableList<String> = ArrayList<String>()

        tabTextList.add("推荐学习");
        tabTextList.add("企业学院");
        tabTextList.add("我的关注");
        mYPKTabLayoutView.setTabTextList(tabTextList);

        mYPKTabLayoutView.addTabSelectedListener { tabPosition ->
            val makeText =
                Toast.makeText(
                    this@MainActivity,
                    "点击了第" + tabPosition + "项",
                    Toast.LENGTH_SHORT
                )
            makeText.setGravity(Gravity.CENTER, 0, 0);
            makeText.show();
        }

属性说明:

属性 说明
tabTextColor tab的文字颜色
tabTextSize tab文字大小(单位:sp)
tab_view_bg 控件背景色
select_tab_color 选中后tab的背景色
arcControlX 值越大,曲线弧度越大
view_bg_corners 控件的圆角大小(单位:dp)

优化计划

...

About

一个自定义tablayout View

License:Other


Languages

Language:Java 77.0%Language:Kotlin 23.0%