美文网首页
Android 主页面底部导航栏 BottomNavigatio

Android 主页面底部导航栏 BottomNavigatio

作者: lodtap | 来源:发表于2021-01-16 20:02 被阅读0次

1. activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="schemas.android.com/apk/res-auto"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    >

    <com.google.android.material.bottomnavigation.BottomNavigationView

        android:id="@+id/nv_navigation"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:layout_marginStart="0dp"

        android:layout_marginEnd="0dp"

        android:background="?android:attr/windowBackground"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintTop_toBottomOf="@id/fragment_container"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintBottom_toBottomOf="parent"

        app:menu="@menu/bottom_nav_menu"

        app:itemIconSize="20dp"  //设置导航栏的图标大小

    />

    <fragment 

        android:id="@+id/fragment_container"

        android:layout_width="match_parent"

        android:layout_height="0dp"

        android:name="androidx.navigation.fragment.NavHostFragment"

        app:defaultNavHost="true"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintTop_toTopOf="parent"

        app:layout_constrainRight_toRightOf="parent"

        app:layout_constraintBottom_toTopOf="@id/nv_navigation"

    />

</androidx.constraintlayout.widget.ConstraintLayout>

相关文章

网友评论

      本文标题:Android 主页面底部导航栏 BottomNavigatio

      本文链接:https://www.haomeiwen.com/subject/aoxoaktx.html