Android開源庫-仿360手機助手底部動畫菜單布局
仿360手機助手底部動畫菜單布局
效果對比:
360手機助手效果演示: | 本庫實現的效果(Icon來自360手機助手,侵刪) |
---|---|
![]() 這里寫圖片描述 |
![]() 這里寫圖片描述 |
xml布局文件
注:為了美觀,講每個Button的高度以及固定,設置wrap_content時候是最大高度,為50dp,如果需要設置特定高度請參見下文的方法表格
<com.brioal.bottomtab.view.BottomLayout
android:id="@+id/main_tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
</com.brioal.bottomtab.view.BottomLayout></code></pre>
數據源添加與基本設置
mList = new ArrayList<>();
mList.add(new TabEntity(R.mipmap.icon_1, "推薦"));
mList.add(new TabEntity(R.mipmap.icon_2, "游戲"));
mList.add(new TabEntity(R.mipmap.icon_3, "軟件"));
mList.add(new TabEntity(R.mipmap.icon_4, "應用圈"));
mList.add(new TabEntity(R.mipmap.icon_5, "管理"));
mBottomLayout.setList(mList); //設置數據源
mBottomLayout.setNews(1, 0); //設置未讀消息
mBottomLayout.setNews(2, 1);
mBottomLayout.setNews(3, 2);
mBottomLayout.setNews(4, 3);
mBottomLayout.setNews(5, 4);
//設置Item點擊事件
mBottomLayout.setSelectedListener(new OnTabSelectedListener() {
@Override
public void onSelected(int position) {
mBottomLayout.cleanNews(position); //清除未讀消息
if (mToast == null) {
mToast = Toast.makeText(MainActivity.this, position + "", Toast.LENGTH_SHORT);
} else {
mToast.setText(position + "");
}
mToast.show();
}
});
這樣設置之后的效果如示例圖所以,已經可以基本使用,本庫還提供其他自定義效果,如下:
xml屬性
Java方法
功能
colorNormal
void setColorNormal(int colorNormal)
設置未選中的時候Icon和文字的顏色
colorSelected
setColorSelect(int colorSelect)
設置選中的時候Icon和文字的顏色
textSize
setTextSize(int textSize)
設置字體的大小
exCircleColor
setExCircleColor(int exCircleColor)
設置外圓顏色
inCircleColor
setInCircleColor(int inCircleColor)
設置內圓顏色
animDuration
setDuration(int duration)
設置點擊漣漪的動畫時長
無
void setList(List<TabEntity> list)
設置數據源,格式為資源文件,菜單名稱
無
void setMenuHeight(int height)
設置菜單高度,默認為50dp,適宜高度
無
void setCurrentIndex(int currentIndex)
設置選中的Tab按鈕下表
無
setSelectedListener(OnTabSelectedListener selectedListener)
設置Item點擊事件
無
setNews(int newSum, int index)
設置指定Item的未讀消息數量
無
cleanNews(int index)
清除指定Item的未讀消息
在項目中添加此組件的方式:
Step 1. 項目的build.gradle文件做如下修改
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. 添加依賴
dependencies {
compile 'com.github.Brioal:BottomTabLayout:1.1'
}
來自:http://www.jianshu.com/p/b3d86c96fa35
本文由用戶 r569594043 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!