android Material Design 底部导航栏

这篇博客介绍了如何在Android中实现Material Design风格的底部导航栏,包括配置gradle依赖、使用BottomNavigationView,以及在MainActivity.java和nav_bottom_item.xml中的设置。注意在XML布局中,使用错误的xmlns:design会导致预览无效果,正确的引用应为xmlns:app。
摘要由CSDN通过智能技术生成

android Material Design 底部导航栏

实现效果

这里写图片描述

配置gradle依赖

compile 'com.android.support:appcompat-v7:25.1.0'
//注意:V4包一定要加,material design是依赖V4包的
//不加,某些类可能报“ClassNotFoundException”
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:design:25.1.0'

使用BottomNavigationView

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.kangda.app.MainActivity">
    <!--一定要加入V4包和Material Design包的依赖-->
    <!--itemIconTint设置图标的颜色-->
    <!--itemTextColor设置文本标题的颜色-->
    <android.support.design.widget.BottomNavigationView
        android:id
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值