
基本上,我试图实现一些类似的照片所附。动物类别的列表(垂直卷轴),它包含一些动物列表(水平卷轴),在每个动物卡片中有一个描述列表(水平卷轴)。
我不使用任何ScrollViews,只使用来自三个RecyclerViews的给定卷轴。
我想滚动橙色卡片和照片卡动物,以保持修复。但是这个卷轴只适用于移动动物卡片,而不是橙色卡片。如果我为每一张橙色卡片设置了一个点击监听器,它将把我发送到给定的屏幕上。
我看到了水平卷轴内的水平滚动在其他应用程序上工作,所以它有可能实现,但我想我错过了一些东西。
我也看到这个问题有很多种形式,但似乎没有答案。
假设我有三个包含它们的类:
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());发布于 2018-10-25 11:57:21
在这里,您定义了水平回收视图(比如descriptionRecyclerView),在下面添加。这将省略父回收视图的滚动,当触摸到回收视图区域时,并控制卷轴。
RecyclerView.OnItemTouchListener mScrollTouchListener = new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_MOVE:
rv.getParent().requestDisallowInterceptTouchEvent(true);
break;
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) { }
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { }
};
descriptionRecyclerView.addOnItemTouchListener(mScrollTouchListener);发布于 2018-10-25 12:35:34
这是一个糟糕的UX,很多嵌套的滚动视图很难与之交互,
您应该将数据拆分到不同的屏幕中,或者只需减少每个布局显示的数据,这样就不必滚动,然后在用户单击并打开新的详细信息屏幕时再次显示它。
或者可以使用可扩展列表项来显示更多数据。
https://stackoverflow.com/questions/52988406
复制相似问题