【发布时间】:2019-03-30 00:21:18
【问题描述】:
基本上,我正在尝试实现类似于所附照片的效果。动物类别列表(垂直滚动),其中包含一些动物列表(水平滚动),并且在每个动物卡片中都有一个描述列表(水平滚动)。
我没有使用任何 ScrollView,只使用三个 RecyclerView 中的给定滚动。
我想滚动橙色卡片和照片卡片动物以保持固定。但卷轴只能移动动物牌,不能移动橙色牌。如果我为每张橙色卡片设置一个点击监听器,它会将我发送到给定的屏幕。
我在其他应用程序上看到了水平滚动中的水平滚动,所以它是可能实现的,但我想我错过了一些东西。
我也看到了这个问题的多种形式,但似乎没有答案。
假设我有三个包含它们的类:
AnimalCategory - 动物名称和列表
动物 - 照片、文字和描述列表
描述 - 属性字段
活动中:
...
animalsAdapter.addCategory(new AnimalCategory(
animalCategoryList.get(i).getName(),
animalCategoryList.get(i).getAnimals()));
animalsRecyclerView.setAdapter(animalsAdapter);
...
在 AnimalsCategoryAdapter 中:
holder.categoryTextView.setText(categoryName);
holder.categoriesRecyclerView.setLayoutManager(new LinearLayoutManager(holder.categoriesRecyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
holder.categoriesRecyclerView.setAdapter(new AnimalsAdapter(animalsCategory.getAnimals(), context));
在 AnimalsAdapter 中:
holder.categoriesRecyclerView.setLayoutManager(new LinearLayoutManager(holder.categoriesRecyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
holder.categoriesRecyclerView.setAdapter(new AnimalAdapter(animalCategory.getAnimals(), context);
在说明中:
Description description = descriptionList.get(position);
holder.propertyTextView.setText(description.getProperty());
【问题讨论】:
标签: android android-recyclerview horizontal-scrolling