底部导航栏四个按钮代表四个颜色,点其中其中一个按钮,则换一种颜色,颜色代码和图标都保存在相应的数组里,具体如下:
使用的开源库是:LuseenBottomNavigation
本应用《任您记)APP项目中用法是依赖:compile ‘com.github.armcha:LuseenBottomNavigation:1.8.2‘
主要代码:
if (bottomNavigationView != null) {
bottomNavigationView.isWithText(false);
bottomNavigationView.isColoredBackground(true);
bottomNavigationView.setTextActiveSize(getResources().getDimension(R.dimen.dp_18));
bottomNavigationView.setTextInactiveSize(getResources().getDimension(R.dimen.dp_18));
bottomNavigationView.setItemActiveColorWithoutColoredBackground(ContextCompat.getColor(this, R.color.colorPrimary));
bottomNavigationView.setFont(Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/chinese_character.ttf"));
}
BottomNavigationItem bottomNavigationItem = new BottomNavigationItem
("待办", color[0], image[0]);
BottomNavigationItem bottomNavigationItem1 = new BottomNavigationItem
("日记", color[1], image[1]);
BottomNavigationItem bottomNavigationItem2 = new BottomNavigationItem
("账单", color[2], image[2]);
BottomNavigationItem bottomNavigationItem3 = new BottomNavigationItem
("纪念日", color[3], image[3]);
bottomNavigationView.addTab(bottomNavigationItem);
bottomNavigationView.addTab(bottomNavigationItem1);
bottomNavigationView.addTab(bottomNavigationItem2);
bottomNavigationView.addTab(bottomNavigationItem3);
bottomNavigationView.setOnBottomNavigationItemClickListener(this);
最后上一下已做好的优雅界面图:
原文地址:http://blog.51cto.com/1206995290qq/2157703