问题是:双重recycleview嵌套,,外层recycleview的item里面图片recycleview会获取到焦点,导致点击图片recycleview部分不会有点击效果,不能跳到文章详情页里面去。
现在想到的解决办法有两种:
第一种:自定义一个recycleview,重写ontouchEvent事件,返回false,没有触摸事件。再替换掉里面图片recycleview就可以了
public class CustomRecyclerView extends RecyclerView {
public CustomRecyclerView(Context context) {
super(context);
}
public CustomRecyclerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public CustomRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onTouchEvent(MotionEvent e) {
// return super.onTo uchEvent(e);
return false;
}
// @Override
// public boolean onInterceptTouchEvent(MotionEvent e) {
return super.onInterceptTouchEvent(e);
// return false;
// }
// @Override
// public boolean dispatchTouchEvent(MotionEvent ev) {
return super.dispatchTouchEvent(ev);
// return false;
// }
}
第二种:在外层recycleview的adapter里面自定义一个点击事件,把外层recycleview的控件点击事件和图片recycleview的点击事件合在一起就行了(感觉第一种的逼格比较高,推荐第一种吧)
public cl