我的haha.xml布局已被android.support.design.widget.AppBarLayout覆盖,如何使haha.xml上的按钮仅显示在AppBarLayout下?
android - LinearLayout被AppBarLayout覆盖-LMLPHP

仅haha.xml布局

android - LinearLayout被AppBarLayout覆盖-LMLPHP

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>

最佳答案

AppBarLayout包裹haha layoutLayoutManager来排列UI元素
例如,您可以使用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>


希望这个帮助

关于android - LinearLayout被AppBarLayout覆盖,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37128564/

10-10 22:39