底部导航库之AHBottomNavigation

来源:互联网 发布:淘宝店铺旺旺在哪里 编辑:程序博客网 时间:2024/06/01 12:08

(这篇文章是我看了网上的很多列子之后总结的,如有雷同,呵呵)
Ahbottomnavigation 是采用 Material Design 风格设计的底部导航库,要求最小版本SDK为16,比较支持3~5个底部Item项,如果过多就不推荐使用Ahbottomnavigation,过少的话,像只有2个这种也不推荐使用。
如图:
3~5个的效果(推荐):
这里写图片描述

只有2个的效果(不推荐):
这里写图片描述

太多的效果(不推荐):
这里写图片描述

可以自行设置底部每个Item项的风格,但是尽量不要把背景色弄的五颜六色的,只要让用户清楚地知道他选择的是哪一个就行了(如果Ahbottomnavigation本身是彩色的,那么文字和图标尽量用白色或黑色,被选中之后一定要高亮,高亮,高亮,重要的事情说三遍)。
效果图:
这里写图片描述
这里写图片描述
这里写图片描述

使用方法
布局文件中引用:

    <com.aurelhubert.ahbottomnavigation.AHBottomNavigation        android:id="@+id/bottom_navigation"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_gravity="bottom" />

在Activity/Fragment中使用:

AHBottomNavigation bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);// Create itemsAHBottomNavigationItem item1 = new AHBottomNavigationItem("Label One", R.drawable.ic_maps_place, Color.parseColor("#455C65"));AHBottomNavigationItem item2 = new AHBottomNavigationItem("Label Two", R.drawable.ic_maps_local_bar, Color.parseColor("#00886A"));AHBottomNavigationItem item3 = new AHBottomNavigationItem("Label Three", R.drawable.ic_maps_local_restaurant, Color.parseColor("#8B6B62"));// Add itemsbottomNavigation.addItem(item1);bottomNavigation.addItem(item2);bottomNavigation.addItem(item3);// Set background colorbottomNavigation.setDefaultBackgroundColor(Color.parseColor("#FEFEFE"));// Change colorsbottomNavigation.setAccentColor(Color.parseColor("#F63D2B"));bottomNavigation.setInactiveColor(Color.parseColor("#747474"));// Use colored navigation with circle reveal effectbottomNavigation.setColored(true);// Set listenerbottomNavigation.setAHBottomNavigationListener(new AHBottomNavigation.AHBottomNavigationListener() {    @Override    public void onTabSelected(int position) {        // Do something cool here...    }});

AHBottomNavigation的jar包可以在此下载
点这里下载

0 0
原创粉丝点击