2016-05-10 12 views
0

Meine haha.xml Layout wurde von android.support.design.widget.AppBarLayout abgedeckt, wie kann ich die Schaltfläche auf der haha.xml nur unter dem AppBarLayout erscheinen? enter image description hereLinearLayout wurde von AppBarLayout abgedeckt

nur haha.xml Layout

enter image description here

PS: 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.william.test.MainActivity" 
    tools:showIn="@layout/activity_main"> 
    <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/haha" /> 
</android.support.design.widget.CoordinatorLayout> 

haha.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/red"> 
    <Button 
    android:layout_width="match_parent" 
    android:layout_height="100dp" 
    android:text="按钮不可用1"/> 

</LinearLayout> 
+0

Sie scheinen kein umliegendes Layout um das AppBarLayout + LinearLayout zu haben. –

+0

@ cricket_007 aktualisiert activity_main.xml enthält alle. –

Antwort

0

Wickeln Sie Ihre AppBarLayout und haha layout durch eine LayoutManager auf UI-Elemente
Zum Beispiel ordnen Sie LinearLayout

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
...> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <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/haha" /> 
    </LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 

Hope this Hilfe

0

Versuchen Sie Folgendes verwenden:

<?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.fragments.myapplication.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" /> 
     <include layout="@layout/haha" /> 
    </android.support.design.widget.AppBarLayout> 
    </android.support.design.widget.CoordinatorLayout> 
+0

Danke. Ich habe activity_main.xml aktualisiert. Tatsächlich enthält es, was du hinzugefügt hast. –

Verwandte Themen