Android中BottomNavigationView的java分割器 1 年,2 月 Questions & Answers 56 如何在Android中为BottomNavigationView提供分隔符?我需要在家和环境之间建立一条小小的界线。
# 1 楼答案 您可以按照建议here为底部导航视图创建背景。如果您已经有了背景,并且由于底部导航视图是一个框架布局,您可以添加一个分隔符,如下所示: 导航\u分隔器。xml <shape android:shape="rectangle"> <size android:width="2dp" /> <solid android:color="#E91E63" /> </shape> 主要活动。xml <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?attr/actionBarSize"> <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/nav_view" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="0dp" android:layout_marginEnd="0dp" android:background="?android:attr/windowBackground" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:menu="@menu/bottom_nav_menu"> <View android:layout_width="2dp" android:layout_height="30dp" android:layout_gravity="center" android:background="@drawable/navigation_divider" /> </com.google.android.material.bottomnavigation.BottomNavigationView> <fragment android:id="@+id/nav_host_fragment_activity_main" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="true" app:layout_constraintBottom_toTopOf="@id/nav_view" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:navGraph="@navigation/mobile_navigation" /> </androidx.constraintlayout.widget.ConstraintLayout> 当然,您需要在菜单中选择偶数个选项
# 1 楼答案
您可以按照建议here为底部导航视图创建背景。如果您已经有了背景,并且由于底部导航视图是一个框架布局,您可以添加一个分隔符,如下所示:
导航\u分隔器。xml
主要活动。xml
当然,您需要在菜单中选择偶数个选项