如何在协调器布局中排列视图



我的collapsible toolbar工作,但覆盖了标题,因为我试图使用nestedscrollview向上滚动。我尝试将其放在相对布局中,但随后toolbar停止工作,不再崩溃。

这是我的布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/cordinator"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#fff"
    tools:context="com.store.android.basic.Introduction">
    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <include
            android:id="@+id/introduction_toolbar"
            layout="@layout/app_toolbar" />
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="10dp">
            <TextView
                android:id = "@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:text="@string/heading"
                android:textColor="#D31F33"
                android:textSize="25sp"
                android:textStyle="bold" />
            <TextView
                android:id = "@+id/sub_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/text_one"
                android:textSize="18sp" />
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

app:layout_behavior="@string/appbar_scrolling_view_behavior">

只需将此行放在NestedScrollView中即可。

最新更新