Приведенное ниже решение не будет перетаскивать нижнюю страницу, если пользователь касается VideoView
.
Концепция проста
- Отключить касание VideoView
- Отключить перетаскивание при касании пользователяVideoView
В вашей деятельности
final LockBottomSheetBehaviour behavior = (LockBottomSheetBehaviour) LockBottomSheetBehaviour.from(bottomSheet);
findViewById(R.id.videoView).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
behavior.setAllowUserDragging(false);
break;
case MotionEvent.ACTION_UP:
behavior.setAllowUserDragging(true);
break;
}
return true;
}
});
В макете замените
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
на
app:layout_behavior="com.package.LockBottomSheetBehaviour"
LockBottomSheetBehaviour.class
import android.content.Context;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
public class LockBottomSheetBehaviour<V extends View> extends BottomSheetBehavior<V> {
private boolean mAllowUserDragging = true;
public LockBottomSheetBehaviour() {
super();
}
public LockBottomSheetBehaviour(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setAllowUserDragging(boolean allowUserDragging) {
mAllowUserDragging = allowUserDragging;
}
@Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
if (!mAllowUserDragging) {
return false;
}
return super.onInterceptTouchEvent(parent, child, event);
}
}