底部导航库之AHBottomNavigation

(这篇文章是我看了网上的很多列子之后总结的,如有雷同,呵呵)
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 items
AHBottomNavigationItem 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 items
bottomNavigation.addItem(item1);
bottomNavigation.addItem(item2);
bottomNavigation.addItem(item3);

// Set background color
bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#FEFEFE"));

// Change colors
bottomNavigation.setAccentColor(Color.parseColor("#F63D2B"));
bottomNavigation.setInactiveColor(Color.parseColor("#747474"));

// Use colored navigation with circle reveal effect
bottomNavigation.setColored(true);

// Set listener
bottomNavigation.setAHBottomNavigationListener(new AHBottomNavigation.AHBottomNavigationListener() {
    @Override
    public void onTabSelected(int position) {
        // Do something cool here...
    }
});

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码的灵魂是bug!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值