android 底部快速button

最快制作页面底部的四个RadioButto
(1)先将compile 'com.hjm:BottomTabBar:1.1.1' 导入build.gradle。
在布局文件里面导入<com.hjm.bottomtabbar.BottomTabBar>把宽高全部都为充满。在创建一个布局fragment方便后面进行使用,里面什么都不用写。

(2)在主类里面创建一个方法init(),
将下面代码直接粘贴,复制
bottomTabBar = (BottomTabBar) findViewById(R.id.bottomTabBar);
//底部导航栏
bottomTabBar.init(getSupportFragmentManager())
.setImgSize(35, 35)
.setFontSize(10)
.setChangeColor(Color.RED, Color.GRAY)
.addTabItem("首页", R.mipmap.ic_nav_home_press, R.mipmap.ic_nav_home, Fragment1.class) 前面第一个是点击后的图片,第二个是点击前的图片
.addTabItem("分类", R.mipmap.ic_nav_class_press, R.mipmap.ic_nav_class, Fragment2.class)
.addTabItem("购物车", R.mipmap.ic_nav_cart_press, R.mipmap.ic_nav_cart, Fragment3.class)
.addTabItem("个人", R.mipmap.ic_nav_user_press, R.mipmap.ic_nav_user, Fragment4.class)
.isShowDivider(false);
最后创建4个fragment,在frangment重写onCreateView的方法,(特别注意导包一定要导android.support.v4.app.Fragment)
View view=inflater.inflate(R.layout.fragment,container,false);
return view;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值