BottomNavigationView
BottomNavigationView copied to clipboard
🔥一个简单的底部导航栏,可以快速集成,简单易用,提供自定义属性,以及默认属性等
简介
一个简单的底部导航栏,可以快速集成,简单易用
问题反馈
欢迎大家加入群组讨论。

使用效果
整体效果
默认
无分割线
自定义线
集成方式
gradle
Step 1. Add the dependency
dependencies {
implementation 'com.winton:bottomnavigationview:1.0.0'
}
用法
XML布局
<com.winton.bottomnavigationview.NavigationView
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/nv"
android:background="@android:color/white"
app:activeTextColor="@android:color/black"
app:unactiveTextColor="#666666"
android:layout_width="match_parent"
android:layout_height="60dp">
</com.winton.bottomnavigationview.NavigationView>
添加module
NavigationView mNV = findViewById(R.id.nv);
List<NavigationView.Model> tabs = new ArrayList<>();
tabs.add(new NavigationView.Model.Builder(R.mipmap.ic_launcher,R.mipmap.ic_launcher).title("主页").build());
tabs.add(new NavigationView.Model.Builder(R.mipmap.ic_launcher,R.mipmap.ic_launcher).title("tab1").build());
tabs.add(new NavigationView.Model.Builder(R.mipmap.ic_launcher,R.mipmap.ic_launcher).title("tab2").build());
mNV.setItems(tabs);
/*在此处监听,可获取到第一次选中到结果*/
mNV.build();
//mNV.check(0); //2.2 版本之后默认选中0
添加监听
mNV.setOnTabSelectedListener(new NavigationView.OnTabSelectedListener() {
@Override
public void selected(int i, NavigationView.Model model) {
Toast.makeText(MainActivity.this,model.getTitle(),Toast.LENGTH_LONG).show();
}
@Override
public void unselected(int i, NavigationView.Model model) {
}
});
显示新消息
/**
* 第一个参数代表Item的位置
* 第二个参数代表是否显示红点
* 第三个参数代表红点第内容
**/
mNV.reminder(0,true,"99");
mNV.reminder(1,true,"···");
mNV.reminder(2,true,"");
参数说明
License
Copyright 2018 Winton
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.