2017-02-21 13 views
0

こんにちは、私はアンドロイドスタジオに新しいです、どんな助けも大歓迎です。BottomNavigationViewに背景色が追加されないようにする方法

何らかの理由で、FrameLayoutに背景色を追加すると、BottomNavigationViewの背景が塗りつぶされます。私はlayout_aboveタグを使用してBottomNavigationViewの上にFrameLayoutを設定し、BottomNavigationViewのIDを与えたので、なぜこれが起こっているのか分かりません。

これはでframeLayoutとBottomNavigationViewを含む私のxmlファイルです:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:design="http://schemas.android.com/apk/res-auto"> 

<FrameLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@id/bottom_navigation_bar" 
    android:layout_alignParentTop="true" 
    android:background="@color/colorPrimaryDark"> 
</FrameLayout> 

<android.support.design.widget.BottomNavigationView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/bottom_navigation_bar" 
    android:layout_gravity="bottom" 
    design:menu="@menu/navigation_menu" /> 

</android.support.design.widget.CoordinatorLayout> 

ここに私のメニューxmlファイル:

<?xml version="1.0" encoding="utf-8"?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android"> 
<item 
    android:id="@+id/action_home" 
    android:title="@string/on_home" 
    android:icon="@drawable/ic_home"/> 

<item 
    android:id="@+id/action_saved" 
    android:title="@string/on_saved" 
    android:icon="@drawable/ic_file_download"/> 

<item 
    android:id="@+id/action_profile" 
    android:title="@string/on_profile" 
    android:icon="@drawable/ic_action_user"/> 

答えて

0

変更このライン

android:layout_above="@id/bottom_navigation_bar" 

ウィットh

android:layout_above="@+id/bottom_navigation_bar" 

希望します。これは、コード

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     xmlns:design="http://schemas.android.com/apk/res-auto"> 
    <RelativeLayout         
     android:layout_width="match_parent" 
     android:layout_height="match_parent"               
     > 
    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/bottom_navigation_bar" 
     android:layout_alignParentTop="true" 
     android:background="@color/colorPrimaryDark"> 
    </FrameLayout> 

    <android.support.design.widget.BottomNavigationView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/bottom_navigation_bar" 
     android:layout_gravity="bottom" 
     android:layout_alignParentBottom="true" 
     design:menu="@menu/navigation_menu" /> 
    </RelativeLayout> 
    </android.support.design.widget.CoordinatorLayout> 

このXML動作するようには思えない

+0

を使用してみてください以下に、あなたのXMLを変更してみてください動作しない場合は、おかげでとにかく – Chris

+0

は感謝を働いたこと、AW甘い私の更新の答え仲間 –

+0

を試してみてください君は! – Chris

関連する問題