我想使用水平回收与垂直回收一起,如谷歌游戏商店,但在我的应用程序,只有第一行,如下图。我使用了滚动视图,但是当我们有大量的数据和分页时,它不像我想要的那样正确。它还设有水平回收和垂直回收的头部部分,当垂直回收器部分滚动到TitleSection of UiTableView in iOS时,水平回收头部分也会发生变化。谢谢!
发布于 2017-07-04 22:42:10
NestedScrollView
作为RecyclerViews
的容器。LinearLayoutManager
设置为具有Horizontal
方向的recycler_view_horizontal
。LinearLayoutManager
设置为具有Vertical
方向的recycler_view_vertical
。RecyclerView.setNestedScrollingEnabled(false)
对RecyclerView
进行平滑滚动。按以下方式设计布局结构:
<?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:id="@+id/layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:titleTextColor="@android:color/white"
app:contentInsetStartWithNavigation="0dp">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/layout_scorll"
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="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/header1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Horizontal Recycler Header"
android:textSize="16sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false" />
<TextView
android:id="@+id/header2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Vertical Recycler Header"
android:textSize="16sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
活动中的:
mRecyclerViewHorizontal.setNestedScrollingEnabled(false);
mRecyclerViewVertical.setNestedScrollingEnabled(false);
mRecyclerViewHorizontal.setHasFixedSize(false);
mRecyclerViewVertical.setHasFixedSize(false);
希望能帮上忙!
发布于 2018-01-30 08:16:50
https://stackoverflow.com/questions/44918510
复制