<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="0dp"
android:layout_height="52.0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_navigation"> </android.support.design.widget.BottomNavigationView>
</android.support.constraint.ConstraintLayout>

在res-->menu添加 xml(如果没有menu就新创建一个)这里我新建一个名为bottom_navigation.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item
android:id="@+id/item_1"
android:icon="@mipmap/ic_launcher"
android:title="首页"/> <item
android:id="@+id/item_2"
android:icon="@mipmap/ic_launcher"
android:title="消息" /> <item
android:id="@+id/item_3"
android:icon="@mipmap/ic_launcher"
android:title="动态" />
<item
android:id="@+id/item_4"
android:icon="@mipmap/ic_launcher"
android:title="我" />
</menu>

测试发现放3-4个最为合适,个人感觉3个最美观

res/color/bottom_nav_seletor.xml 修改文字选择颜色

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimary" android:state_checked="true" />
<item android:color="@color/colorPrimary" android:state_pressed="true" />
<item android:color="@color/colorPrimary" android:state_selected="true" />
<item android:color="@color/black" />
</selector>

在bottom_navigation.xml 增加属性

app:itemIconTint="@color/bottom_nav_seletor" 设置选择器  这个时候导航导航设置为3个能看出来效果
修改图标类似res/drawable 新建选择器
 android:icon="@mipmap/ic_launcher" 这地方设置选择器的XML文件名就可以了

BottomNavigationView 使用的更多相关文章

  1. 关于Android中使用BottomNavigationView切换横屏导致返回主页的问题

    问题: 如图,"发现"页即为主页,然后我们切换到"我"页,一切正常. 那么问题来了,如果切换到"我"页后把手机横屏,则会出现下面的情况. 嗯 ...

  2. 第三十七篇-BottomNavigationVIew底部导航的使用

    效果图: 添加底部导航和viewpaper 设置底部导航在底部 app:layout_constraintBottom_toBottomOf="parent" 新建四个fragme ...

  3. Android 底部按钮BottomNavigationView + Fragment 的使用(二)

    这里来试验BottomNavigationView + Fragment 底部按钮通过点击底部选项,实现中间的Fragment进行页面的切换. 使用BottomNavigationView 控件,实现 ...

  4. Android 底部按钮BottomNavigationView + Fragment + viewPager 的使用(一)

    实现的效果,左右滑动,底部栏跟着滑动,中间加的是分帧的页面        上代码:主页面activity_main.xml <?xml version="1.0" encod ...

  5. BottomNavigationView结合ViewPager

    BottomNavigationView是Google推出的底部导航栏组件,在没有这些底部导航组件之前,Android开发者多使用的是RadioGroup,在上一个项目开发中我们使用了Google的B ...

  6. BottomNavigationView的使用

    BottomNavigationView的使用 废话少说, 先看东西 依赖 implementation 'com.android.support:design:26.1.0' 布局 //用这个控件需 ...

  7. 014 Android BottomNavigationView 底部导航组件使用

    1.导入BottomNavigationView组件(点击下载按钮,安装组件) 2.新建菜单 (1)app--->src-->main--->res ,选中res目录右击new--- ...

  8. android BottomNavigationView 底部显示3个以上的item

    你现在可以用app:labelVisibilityMode="[labeled, unlabeled, selected, auto] labeled 所有的标签都是可见的. unlabel ...

  9. BottomNavigationView 的使用

    转载请注明出处:http://blog.csdn.net/wl9739/article/details/52875710 BottomNavigationView 很早之前就在 Material De ...

随机推荐

  1. C语言实现Winsocket网络传输数据时乱码问题

    问题描述:输入中文字符时在数据结尾总是有别的字符冒出 解决办法: recvBuf[ret] = '\0';//接收数据的数组,表示存储的数据截止,后面没有数据了 再运行,传输正常. 提示:C语言基础知 ...

  2. oracle数据库SQL入门

    1.oracle数据库的下载.安装.卸载 Oracle下载: Oracle下载链接地址:http://www.oracle.com/technetwork/cn/database/enterprise ...

  3. Future模式介绍及入门使用

    FutureClient代码实现: package com.hjf.future; public class FutureClient { /** * 请求客户端 * @param queryStr ...

  4. get 乱码解决方案

    1.针对Post方式提交的请求如果出现乱码,可以每次在request解析数据时设置编码格式: request.setCharacterEncoding("utf-8"); 也可以使 ...

  5. tp5阿里云短信发送

    到阿里云下载php版demo,下完整版的,不是轻量级的; 框架  :TP5 把下载下来的文件放到extend里面 文件名:alimsg 里面的文件 import('alimsg.api_demo.Sm ...

  6. 剑指Offer 49. 把字符串转换成整数 (字符串)

    题目描述 将一个字符串转换成一个整数(实现Integer.valueOf(string)的功能,但是string不符合数字要求时返回0),要求不能使用字符串转换整数的库函数. 数值为0或者字符串不是一 ...

  7. 剑指Offer 31. 整数中1出现的次数(从1到n整数中1出现的次数) (其他)

    题目描述 求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1.10.11.12.13因此共出现6次,但是对于后面问题他就没辙了. ...

  8. 【转】20-TCP 协议(滑动窗口——基础)

    https://blog.csdn.net/q1007729991/article/details/70142341 相信大家都遇到过这样的场景: 同学 Luffy 给你打电话,让你记下一串手机号码, ...

  9. latex之行内公式与行间公式

    1.行内公式 我是对行内公式的测试$f(x)=1+x+x^2$ 2.行间公式 单行不编号 \begin{equation} \int_0^1(1+x)dx \end{equation} 结果为: 单行 ...

  10. yaf nginx 设置

    #test1server { listen 80; listen [::]:80; root /vagrant_data/aaa/public; index index.html index.htm ...