Open Morteza-Rastgoo opened 9 years ago
There is an attribute called swipeOffsetRight
.Do you want this attribute? I read you refer this to other issue.
This is not what i'm talking about here! your answer is for my other issue!
Sorry for that.I misunderstanding your issue.You want to use recyclerview in Viewpager,don't you?
I also.
Yes. I have a this hierarchy :
Fragment > ViewPager > ChildFragment > UltimateRecyclerView > SwipeItem
The problem is that the view pager intercepts the touch event and i can't swipe item(SwipeHold).
@mori-honest Is the viewpager swipeable?
Yes, view pager is swipeable.
I have a solution. Will post in an hour
I have read many blogs and sites with tipps.... I only found one acceptable solution for me.
You have to make your own ViewPager class:
public class OwnViewPager extends ViewPager {
private boolean enabled;
public OwnViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
this.enabled = true;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return this.enabled && super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return this.enabled && super.onInterceptTouchEvent(event);
}
public void setPagingEnabled(boolean enabled) {
this.enabled = enabled;
}
}
Use setPagingEnabled(boolean)
to en/disable swipe for the ViewPager. Also a solution is to make this accessable via xml.
I implemented swipe layout like the example and it worked perfectly, but when i moved the swipeRecyclerView inside a child fragment that is inside a
ViewPager
, swipe doesn't intercept touch event and instead, viewpager swipes the fragments... What can i do to fix this?