我正在使用Android應用程序並從設計庫中實現BottomNavigationView
。我看過很多例子,我無法弄清楚我的佈局有什麼問題。 BottomNavigationView
不顯示爲全寬度。BottomNavigationView不是全寬
另一個問題是狀態欄顏色沒有得到應用。
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Include the toolbar -->
<include layout="@layout/toolbar"/>
<RelativeLayout android:id="@+id/fragment_container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@android:color/white"
app:itemTextColor="@android:color/white"
app:menu="@menu/bottom_navigation_main"/>
</android.support.design.widget.CoordinatorLayout>
toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
編輯: 的狀態加入溶液顏色不設置
android:fitsSystemWindows="true"
(colorPrimaryDark) status bar color not working on android v21?
Bottom Nav在Google Play Newstand中看起來很寬,所以我認爲我的佈局存在問題。我打算很快添加第三個菜單項。 – midhunhk
@midhunhk是的,這是可能的。我爲此添加了解決方案。但安迪是正確的,你應該遵循設計規範。 –