Open jeroenbeuz opened 7 years ago
Also happens when you include all the seekbars in your testapp inside an ScrollView. The slightest vertical movement results in focus loss. So it's not RecyclerViewAdapter related.
Solved by setting an ontouchlistener:
recyclerViewHolder.seekbar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action)
{
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle Seekbar touch events.
v.onTouchEvent(event);
return true;
}
});
When the HueSeekBar is placed in a RecyclerViewAdapter, changing the seekbar by dragging it easily loses it's focus. In the testapp the focus is kept when you keep your finger inside the RelativeLayout view. Within an adapter the focus is lost on the slightest vertical movement.