android 底部去除list渐变,GitHub - Mystery0Tools/BottomTabView: 使用LinearLayout实现的底部Tab,可以给图标设置渐变效果。...

BottomTabView

68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d79737465727930546f6f6c732f426f74746f6d546162566965772e73766768747470733a2f2f7472617669732d63692e6f72672f4d79737465727930546f6f6c732f426f74746f6d546162566965772e7376673f6272616e63683d6d6173746572

Download

68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4d79737465727930546f6f6c732f426f74746f6d546162566965772e73766768747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f4d79737465727930546f6f6c732f426f74746f6d546162566965772e737667

通过Gradle集成:

在应用级的build.gradle中添加依赖:

dependencies {

implementation 'vip.mystery0.tools:bottomtabview:x.x.x'

}

或者通过Maven:

vip.mystery0.tools

bottomtabview

x.x.x

pom

具体效果

preview.gif

如何使用

往您的布局文件中添加控件

android:id="@+id/bottomTabView"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

配置属性

获取控件实例:

BottomTabView bottomTabView = findViewById(R.id.bottomTabView);

除了设置菜单项和设置当前选中的项,其他的自定义配置都通过BottomTabViewConfig类定义。

构建菜单项

List menuList = new ArrayList<>();

menuList.add(new BottomTabItem("11", R.drawable.ic_android_black_24dp));

menuList.add(new BottomTabItem("12", R.drawable.ic_android_black_24dp));

menuList.add(new BottomTabItem("33133", R.drawable.ic_android_black_24dp));

菜单项必须是 BottomTabItem 类的对象,对应的构造函数传入的是现在的菜单名称和显示的 drawable 资源。

构造函数的第二个参数必须是 drawable 的资源引用,必须是矢量图资源(用于着色)。

设置菜单项

bottomTabView.setMenuList(menuList);

自定义配置

bottomTabView.getConfig()

.setSelectedColor(Color.BLACK)//设置选中的条目颜色

.setUnSelectedColor(Color.BLUE)//设置未选中条目颜色

.setMarginTop(16f)//设置距离顶部间距,单位dp

.setMarginBottom(24f)//设置距离底部间距,单位dp

.setItemIconSize(24f)//设置图标大小,单位dp

.setItemTextSize(24f)//设置文字大小,单位sp

.setLineHeight(1f)//设置顶部分割线高度,单位px

.isShowRipple(true)//是否显示点击时水波效果

.isShowGradientColors(false)//是否显示渐变图标(需要设置渐变的颜色数组)

.setGradientColors(new int[]{Color.WHITE, Color.BLACK});//设置渐变颜色数组

bottomTabView.init();//更新视图

自定义属性

属性

值类型

说明

selected_color

color

选中条目颜色

unselected_color

color

未选中条目颜色

margin_top

dimension

距离顶部间距

margin_bottom

dimension

距离底部间距

line_height

dimension

分割线高度

item_text_size

dimension

菜单项文字大小

item_icon_size

dimension

菜单项图标大小

show_ripple

boolean

是否显示点击水波效果

show_gradient_colors

boolean

是否显示渐变图标

设置当前选中条目

bottomTabView.setCheckedItem(2);

设置菜单项点击监听

bottomTabView.setOnItemSelectedListener(new BottomTabView.OnItemSelectedListener() {

@Override

public void onItemSelected(@NotNull BottomTabItem bottomTabItem) {

//Do Something you want to do

}

});

通过index获取item实例

bottomTabView.findItem(index);

通过BottomTabItem对象获取对应的index

bottomTabView.indexOf(BottomTabItem);

LICENSE

Copyright (C) 2018 Mystery0.

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值