2016-06-14 12 views
0

2つのツールバーが画面上部に1つ、画面下部にもう1つあります。現在のところ、下のものはまだ一番上に表示されています。どうすれば解決できますか?ツールバーが下部の代わりに上部に表示されます

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" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="com.example.x.fresh.MainActivity"> 

<android.support.design.widget.AppBarLayout 
    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> 

<include layout="@layout/content_main" /> 

<include 
    layout="@layout/toolbar_bottom" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true"/> 

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

toolbar_bottom.xml

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v7.widget.Toolbar 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/toolbar2" 
android:minHeight="?attr/actionBarSize" 
android:background="@color/primary" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

+0

を撮影し、あなたは 'content_main'内部toolbar_bottom'を含むことができ、 '? –

+0

それでも同じ効果があります。 – purplewind

答えて

0

あなたがrelativeLayoutを使用していない場合は、android:layout_alignParentBottom="true"は意味がありません。

使用この

<?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" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="com.example.x.fresh.MainActivity"> 

<RelativeLayout 
    android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    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> 



<include layout="@layout/content_main" 
      android:layout_below="@+id/appbar" 
      android:id="@+id/content"/> 

<include 
    layout="@layout/toolbar_bottom" 
    android:layout_below="@+id/content" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true"/> 

</RelativeLayout> 

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

appbarとは何ですか? purplewind

+0

@purplewind appbarはIDです'android.support.design.widget.AppBarLayout' –

+0

あなたはトップツールバーのIDを意味しますか? purplewind

0

HIしてください例以下

<?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" 
    android:fitsSystemWindows="true"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary"/> 

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


     <include 
      layout="@layout/test"/> 

     <include 
      android:id="@+id/bottombar" 
      layout="@layout/custom_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true"/> 
    </RelativeLayout> 
</android.support.design.widget.CoordinatorLayout> 

あなたは、画面を確認することができますだけで相対的なレイアウトに

を追加enter image description here

+0

はい、上記の私のコード例に見られるように、私はすでに行いました。私はタグに追加 – purplewind

+0

HI 2つの答えを追加しただけでcordinatorLayout内の相対的なレイアウトを追加したり、Hi.You @roman_empire代わりに相対的なレイアウトを使用するか、コーディネーターのレイアウト – Sach

+0

ことができ、このために私の例をチェックしてみてくださいそれらのいずれかを削除するか、それらをマージしてください。おはよう –

関連する問題