zoukankan      html  css  js  c++  java
  • bottomNavigationBar 底部导航tab MD

    1.先上图:

    此底部Tab完全可以满足日常的开发

    2.使用:

            很简单,使用Gradle构建:compile ‘com.ashokvarma.android:bottom-navigation-bar:0.9.5'

    3.在布局文件中使用

       <com.ashokvarma.bottomnavigation.BottomNavigationBar  

                    android:layout_gravity="bottom"  

                    android:id="@+id/Tab"  

                    android:layout_width="match_parent"  

                    android:layout_height="wrap_content"/>

    4.在Activity中实例化控件,为控件设置属性

     

    BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);

     bottomNavigationBar .addItem(new BottomNavigationItem(R.drawable.ic_home_white_24dp,"Home")) 

      .addItem(new BottomNavigationItem(R.drawable.ic_book_white_24dp,"Books"))

      .addItem(new BottomNavigationItem(R.drawable.ic_music_note_white_24dp,"Music")) 

      .addItem(new BottomNavigationItem(R.drawable.ic_tv_white_24dp,"Movies & TV")) 

      .addItem(new BottomNavigationItem(R.drawable.ic_videogame_asset_white_24dp,"Games")) 

      .initialise();

     

    5.设置监听事件,监听事件有三种状态:

    • 当Item被选中状态
    • 当Item不被选中状态
    • 当Item再次被选中状态

      bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener(){

      @Override public void onTabSelected(int position) { } 

      @Override public void onTabUnselected(int position) { } 

      @Override public void onTabReselected(int position) { } 

     }); 

  • 相关阅读:
    小记css的margin collapsing
    linux—select具体解释
    搜索引擎技术之概要预览
    多线程和多进程的差别(小结)
    Android Bundle类
    Android中Preference的使用以及监听事件分析
    layoutSubviews总结
    win7下jdk安装环境变量配置
    LSPCI具体解释分析
    将二叉树转换成双向链表
  • 原文地址:https://www.cnblogs.com/qianyukun/p/5367070.html
Copyright © 2011-2022 走看看