Android_BottomTabBar

来源:互联网 发布:c语言的未来 编辑:程序博客网 时间:2024/06/03 23:05

一:依赖

compile 'com.hjm:BottomTabBar:1.1.1'

二:布局

<com.hjm.bottomtabbar.BottomTabBar        android:id="@+id/bottomTabBar"        android:layout_width="match_parent"        android:layout_height="match_parent">    </com.hjm.bottomtabbar.BottomTabBar>

三:代码

public class MainActivity extends AppCompatActivity {    @BindView(R.id.bottomtabbar)    BottomTabBar bottomtabbar;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        ButterKnife.bind(this);        bottomtabbar.init(getSupportFragmentManager())                .setImgSize(25, 25)                .setFontSize(8)                .setTabPadding(4, 6, 10)                .setChangeColor(Color.RED, Color.BLACK)                .addTabItem("精选", R.drawable.choiceness, ChoicenessFragment.class)                .addTabItem("专题", R.drawable.dissertation, DissertationFragment.class)                .addTabItem("发现", R.drawable.discover, DiscoverFragment.class)                .addTabItem("我的", R.drawable.my, MyFragment.class)                .isShowDivider(false)                .setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {                    @Override                    public void onTabChange(int position, String name) {                    }                })                .setTabBarBackgroundResource(R.drawable.bottom_bg)                .setBackgroundResource(R.drawable.bg_blue);    }}




原创粉丝点击