BottomTabBar实现底部导航页
来源:互联网 发布:python 2.7 idle 编辑:程序博客网 时间:2024/06/05 16:56
1.导依赖:
compile 'com.hjm:BottomTabBar:1.0.0'
2.在XML中定义一下该控件:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="liuhao.baway.com.liuhao_weekone_demo.MainActivity"> <com.hjm.bottomtabbar.BottomTabBar android:id="@+id/bottomtabbar" android:layout_width="match_parent" android:layout_height="match_parent"></com.hjm.bottomtabbar.BottomTabBar> </RelativeLayout>
3.定义每个Fragment:
public class OneFragment extends Fragment{ @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment1, container, false); return view; }}
4.MainActivity实现的代码:
public class MainActivity extends AppCompatActivity {private BottomTabBar mb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mb=(BottomTabBar)findViewById(R.id.bottom_tab_bar); mb.init(getSupportFragmentManager()) .setImgSize(50,50) .setFontSize(8) .setTabPadding(4,6,10) .setChangeColor(Color.RED,Color.DKGRAY) .addTabItem("月光茶人",R.drawable.tab_home, OneFragment.class) .addTabItem("优惠",R.drawable.tab_topic, TwoFragment.class) .addTabItem("购物车",R.drawable.main_index_cart_normal, ThreeFragment.class) .addTabItem("我的",R.drawable.main_index_my_normal, FourFragment.class) .isShowDivider(false) .setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() { @Override public void onTabChange(int position, String name) { } }); }}BottomTabBar的几种属性:
tab_bar_backgroundBottomTabBar的整体背景颜色tab_img_width图片宽度tab_img_height图片高度tab_font_size文字尺寸tab_padding_top上边距tab_img_font_padding图片文字间隔tab_padding_bottom下边距tab_isshow_divider是否显示分割线tab_divider_height分割线高度tab_divider_background分割线背景tab_selected_color选中的颜色tab_unselected_color未选中的颜色显示的效果:
阅读全文
0 0
- BottomTabBar实现底部导航页
- BottomTabBar底部导航页
- Android--------使用BottomTabBar实现底部导航页
- 使用BottomTabBar实现底部导航页
- Android--使用BottomTabBar实现底部导航页
- Android--------使用BottomTabBar实现底部导航页
- 使用BottomTabBar+Fragment实现底部导航页
- Android--------使用BottomTabBar实现底部导航页
- Android---使用BottomTabBar实现底部导航页
- Android--------使用BottomTabBar实现底部导航页
- BottomTabBar实现底部导航栏
- 底部导航栏 BottomTabBar
- BottomTabBar底部导航模版
- 使用BottomTabBar实现底部导航,MVP网络框架,retrofit解析
- Android——BottomTabBar实现底部导航栏
- //BottomTabBar实现底部选项卡
- 底部导航:BottomTabBar的简单应用
- 底部导航:BottomTabBar的简单应用
- Redis系列(二)持久化
- html为视频添加播放暂停按钮
- Tomcat9.0 debug启动超时
- 视频
- 机器学习系列(11)_Python中Gradient Boosting Machine(GBM)调参方法详解
- BottomTabBar实现底部导航页
- 如何在ubuntu上安装 LAMP 堆栈
- 【Luogu1345】周游加拿大(动态规划)
- ES6系列之---字符串的扩展函数
- [题解] NOIP2012 国王游戏(数论+高精)
- 服务器ip配置 & 策略路由配置
- 软考学习-数学建模
- ubuntu16.04安装CPU版SSD及caffe配置,训练及测试过程
- AdvancedInstaller打包工具使用(一)