RecyclerView内NestedScrollView内CoordinatorLayout
我有这样的布局:RecyclerView内NestedScrollView内CoordinatorLayout
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/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.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_margin="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/avatar_placeholder"
/>
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_marginLeft="20dp"
android:id="@+id/list"
android:orientation="horizontal"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
正如你可以看到有CoordinatorLayout
与NestedScrollView
里面。并且在NestedScrollView
里面有水平的RecyclerView
。因此,此布局的行为如下:
可以看到,问题出在RecyclerView
。当我拖动它时,Toolbar
不会隐藏。在同一时间,当我拖动皮革ImageView
Toolbar
隐藏。如何解决这个问题?
只需添加'recyclerView.setNestedScrollingEnabled(true);'不能解决问题。可能是我应该添加更多的东西? – borune
请看我提供的示例 – Boukharist
我试图将OffsetChangeListener添加到AppBar,但它不会触发,当我拖动RecyclerView时,我认为它会导致RecyclerView方向不同 – borune
recylcer.nestedScrollingEnabled(假)做我想做
工具栏躲在图像是否正确? – Anonymous