导入依赖
implementation 'com.hjm:BottomTabBar:1.1.1'
布局控件
<com.hjm.bottomtabbar.BottomTabBar
android:id="@+id/bottom_tab_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:hjm="http://schemas.android.com/apk/res-auto"
hjm:tab_bar_background="#ffff"
hjm:tab_img_font_padding="0dp"
hjm:tab_img_height="70dp"
hjm:tab_img_width="70dp"
hjm:tab_padding_bottom="5dp"
hjm:tab_padding_top="8dp"
></com.hjm.bottomtabbar.BottomTabBar>
核心代码
tabBar = findViewById(R.id.bottom_tab_bar);
tabBar.init(getSupportFragmentManager())
.addTabItem("电影",R.drawable.film_selected,R.drawable.film_fault,FragmentOne.class)
.addTabItem("影院",R.drawable.cinema_selected,R.drawable.cinema_default,FragmentTwo.class)
.addTabItem("我的",R.drawable.my_selected,R.drawable.my_default,FragmentThree.class);