当前位置: 移动技术网 > 移动技术>移动开发>Android > Android实现360手机助手底部的动画菜单

Android实现360手机助手底部的动画菜单

2019年07月24日  | 移动技术网移动技术  | 我要评论

首先来看下我们实现的效果和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>

数据源添加与基本设置

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 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'
  }

总结

以上就是这篇文章的全部内容了,希望能对各位android开发者们有所帮助,如果有疑问大家可以留言交流。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网