【发布时间】:2015-08-19 04:35:36
【问题描述】:
我正在尝试按照 Google Docs 使用 CoordinatorLayout,但我遇到了 CoordinatorLayout 内的 ScrollView 的问题。基本上,向下滚动时,工具栏通常会与 RecyclerView 或 Listview 一起折叠。现在有了 ScrollView,它就不会崩溃。
<android.support.design.widget.CoordinatorLayout
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"
>
<TextView
android:id="@+id/tv_View"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/filler"
style="@style/TextAppearance.AppCompat.Large"
/>
</ScrollView>
<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"
app:layout_scrollFlags="scroll|enterAlways"
/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
-
在
CoordinatorLayout中使用NestedScrollView代替ScrollView,也适用于BottomNavigationView。 -
或者你可以
ScrollView和android:nestedScrollingEnabled="true"
标签: android toolbar android-scrollview android-toolbar coordinator-layout