Android layout 安卓视差滚动
我需要滚动我的AppBarLayout,并使用我的RecyclerView使折叠工具栏Layout折叠,并使其在子ImageView上进行视差滚动 我使用NestedScrollView成功地做到了这一点,但它与RecyclerView不起作用Android layout 安卓视差滚动,android-layout,android-recyclerview,android-design-library,android-appbarlayout,android-collapsingtoolbarlayout,Android Layout,Android Recyclerview,Android Design Library,Android Appbarlayout,Android Collapsingtoolbarlayout,我需要滚动我的AppBarLayout,并使用我的RecyclerView使折叠工具栏Layout折叠,并使其在子ImageView上进行视差滚动 我使用NestedScrollView成功地做到了这一点,但它与RecyclerView不起作用 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/leagueDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LeagueActivity">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/leagueCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/leagueAppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
我试图使AppBarLayout的每个子级都有一个scrollFlag,如图所示
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/leagueCollapsingToolBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/leagueTopClub"
android:layout_width="match_parent"
android:layout_height="260dp"
android:src="@drawable/arsenal_squad"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.CollapsingToolbarLayout>
我试着在这里使用NestedScrollbar,它成功了,但我需要一个RecyclerView
<android.support.v7.widget.RecyclerView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/leagueRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:scrollbars="vertical"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
...
</android.support.v4.widget.DrawerLayout>."
...
."
请帮忙,我已经尝试过向CoordinatorLayout的每个子级添加scrollFlags,但没有成功。您的
RecyclerView
确实需要与AppBarLayout
同级,而不是它的子级。否则,您的布局似乎没问题,只需将RecyclerView
移动到CoordinatorLayout
<CoordinatorLayout>
<AppBarLayout>
...
</AppBarLayout>
<RecyclerView />
</CoordinatorLayout>
...
您的RecyclerView
确实需要与AppBarLayout
同级,而不是您的子级。否则,您的布局似乎正常,只需将RecyclerView
移动到协调布局
<CoordinatorLayout>
<AppBarLayout>
...
</AppBarLayout>
<RecyclerView />
</CoordinatorLayout>
...
我尝试过,但它仍然不起作用。当CoordinatorLayout是根布局时,我可以让它起作用。现在我想知道CoordinatorLayout是否可以是DroperLayout的子项,并且仍然可以使用折叠工具栏。是的,我没有问题。我尝试过,但它仍然不起作用。当CoordinatorLayout是根布局。现在我想知道CoordinatorLayout是否可以是DroperLayout的子项,并且仍然可以使用折叠工具栏。是的,我对此没有问题。