Android开源库-仿360手机助手底部动画菜单布局

Home / Android MrLee 2016-9-30 2987

效果对比:

360手机助手效果演示:本库实现的效果(Icon来自360手机助手,侵删)

Android开源库-仿360手机助手底部动画菜单布局

Android开源库-仿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>

 

数据源添加与基本设置

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方法功能
colorNormalvoid setColorNormal(int colorNormal)设置未选中的时候Icon和文字的颜色
colorSelectedsetColorSelect(int colorSelect)设置选中的时候Icon和文字的颜色
textSizesetTextSize(int textSize)设置字体的大小
exCircleColorsetExCircleColor(int exCircleColor)设置外圆颜色
inCircleColorsetInCircleColor(int inCircleColor)设置内圆颜色
animDurationsetDuration(int duration)设置点击涟漪的动画时长
void setList(Listlist)设置数据源,格式为资源文件,菜单名称
void setMenuHeight(int height)设置菜单高度,默认为50dp,适宜高度
void setCurrentIndex(int currentIndex)设置选中的Tab按钮下表
setSelectedListener(OnTabSelectedListener selectedListener)设置Item点击事件
setNews(int newSum, int index)设置指定Item的未读消息数量
cleanNews(int index)清除指定Item的未读消息

方法就这些,使用也不难.

添加依赖库的方法

在项目中添加此组件的方式:

Step1. 项目的build.gradle文件做如下修改

allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }

 

Step2. 添加依赖

dependencies {
            compile 'com.github.Brioal:BottomTabLayout:1.1'
    }

   

本文链接:https://www.it72.com/10715.htm

推荐阅读
最新回复 (0)
返回