BottomBar使用
开源地址:https://github.com/roughike/BottomBar
PS:如果觉得这个系列的每篇文章太长,那就直接看视频吧
运行效果
使用步骤
1. 在Module的build.gradle添加依赖
compile 'com.roughike:bottom-bar:2.0.2'
2. 创建底部Tab的配置文件res/xml/bottombar_tabs.xml:
icon:Tab的图片,注意图片不能是透明的,不能存在padding, 可使用Generic Icon Generator生成,
选择“Trim”, Padding设置为0dpbarColorWhenSelected: 当Tab被选中时BottomBar的背景颜色
3. 在布局中添加BottomBar
bb_tabXmlResource: 指定BottomBar底部Tab的布局文件
bb_inActiveTabColor: 设置未选中Tab的文本颜色
bb_activeTabColor:设置选中Tab的文本颜色
4. 设置点击监听
public class MainActivity extends Activity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);bottomBar.setOnTabSelectListener(new OnTabSelectListener() {@Overridepublic void onTabSelected(@IdRes int tabId) {if (tabId == R.id.tab_favorites) {// The tab with id R.id.tab_favorites was selected,// change your content accordingly.}}});}
}
欢迎关注微信公众号

本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
