【发布时间】:2018-02-15 19:26:51
【问题描述】:
我试图让 AppBarLayout 只滚动它的一个子级,而不滚动其中的 ToolBar。
但是,当我从工具栏中删除 layout_scrollflags=scroll 时,没有任何滚动。
是否可以在 AppBarLayout 滚动中只有一个视图而不是工具栏?
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<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="?actionBarSize"
android:theme="@style/BarTheme"
app:title="@string/my">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|start"
android:src="@{ViewModel.showingDropdown ? @drawable/ic_arrow_drop_up_white_24dp : @drawable/ic_arrow_drop_down_white_24dp}"
android:tint="@color/ring_blue"
android:visibility="@{ViewModel != null ? View.VISIBLE : View.GONE}" />
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/widget_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
该代码的结果是没有滚动,但是当我将 layout_scrollflags=scroll 添加到工具栏时,工具栏和 FrameLayout 都会滚动,这是我不想要的
【问题讨论】:
标签: android android-coordinatorlayout