我在布局中使用ScrollView,并尝试使用 CoordinatorLayout 中的新design support library

我的布局文件如下所示:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

  <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
      ...
    </LinearLayout>
  </ScrollView>
  <android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content">
    <android.support.v7.widget.Toolbar ... />
  </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>

测试时,滚动 View 仅占据屏幕的一部分。什么地方出了错?

最佳答案

标准ScrollView仅打算用作父级。您需要将ScrollView更改为 android.support.v4.widget.NestedScrollView

AppBarLayout 的引用文档中可以看到一个示例。

07-24 09:49
查看更多