- 前几天在网上看到FlycoTabLayout这个库,功能非常强大,里面也有三个控件,有兴趣的小伙伴可以看看Github的开源库FlycoTabLayout地址,这里只介绍CommonTabLayout这种,替换传统TabLayout + ViewPager + Fragment ,不需要太复杂的繁琐设置,也无需创建Drawable文件,所以这里还是有必要记录一下,这里为大家分享首页菜单栏切换,CommonTabLayout+ViewPager可实现滑动点击切换页面效果下面贴依赖出来
implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.2@aar'
CommonTabLayout + ViewPger滑动切换
- 首先MainActivity的布局文件,很简单只有一个ViewPager + CommonTabLayout,如下:
<?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:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.v4.view.ViewPager
and