LuseenBottomNavigation
介绍:
又一个底部导航,支持平板模式。
运行效果:
使用说明:
依赖
Gradle:
compile 'com.github.armcha:LuseenBottomNavigation:1.4.0'
Maven:
<dependency>
<groupId>com.github.armcha</groupId>
<artifactId>LuseenBottomNavigation</artifactId>
<version>1.4.0</version>
<type>pom</type>
</dependency>
用法
在布局中添加BottomNavigationView
<com.luseen.luseenbottomnavigation.BottomNavigation.BottomNavigationView
android:id="@+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
添加BottomNavigation的item
BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottomNavigation);
BottomNavigationItem bottomNavigationItem = new BottomNavigationItem
("Record", getResources().getColor(R.color.firstColor), R.drawable.ic_mic_black_24dp);
BottomNavigationItem bottomNavigationItem1 = new BottomNavigationItem
("Like", getResources().getColor(R.color.secondColor), R.drawable.ic_favorite_black_24dp);
bottomNavigationView.addTab(bottomNavigationItem);
bottomNavigationView.addTab(bottomNavigationItem1);
然后设置OnBottomNavigationItemClickListener
bottomNavigationView.setOnBottomNavigationItemClickListener(new BottomNavigationView.OnBottomNavigationItemClickListener() {
@Override
public void onNavigationItemClick(int index) {
Toast.makeText(MainActivity.this, "Item " +index +" clicked", Toast.LENGTH_SHORT).show();
}
});
如果你使用了ViewPager,你可以把它喝BottomNavigationView联系起来:
bottomNavigationView.setViewPager(yourPager , colorResources , imageResources);
使用viewPager的时候你可以停用slide动画
bottomNavigationView.disableViewPagerSlide();
自定义
你可以激活平板模式
bottomNavigationView.activateTabletMode();
bottomNavigationView.isWithText(true);
bottomNavigationView.isColoredBackground(false);
bottomNavigationView.setItemActiveColorWithoutColoredBackground(yourColor);
你可以去掉BottomNavigationView的阴影,调用:
bottomNavigationView.disableShadow();
已下载
0