BottomBar的使用:
导入配置文件:
compile ‘com.roughike:bottom-bar:2.2.0’
(注意:网上的最新的是2.3.1,Android stduio 2.3.3不能用,提示什么版本不一致啥的!所以只能使用2.2.0)
在布局文件中加载BottomBar:
<com.roughike.bottombar.BottomBar
android:id="@+id/bottombar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
app:bb_behavior="shy"
app:bb_tabXmlResource="@xml/bottombar_tabs_five"
>
</com.roughike.bottombar.BottomBar>
注意:
bb_behavior属性有三个,shy表示图片文字都能显示,shifting表示显示当前点击的图标和文字,其他的只显示图片,简单点就是shy有图片和文字,shfting只有一个文字。
bb_behavior:
shy:布局只能是CoordinatorLayout,我用了个LineataLtout,立马报错。
shfting:示显示当前点击的图标和文字
bb_tabXmlResource:
加载布局文件。这个非常麻烦,没有提示的,完全靠手动敲代码。一般也只有用到三个属性,icon,id,title,
加在tabs中:
barColorWhenSelected=”#FE3D81”:
当前点击事件背景图变颜色
inActiveColor=”#00FF00”
文字和图标影藏时的颜色,作用于 icon 和 title
activeColor=”#FF0000”
文字和图标点击选中时时的颜色,作用于 icon 和 title。