Don't blame me if it doesn't work, but in the view of time, I have a rough idea to start with. ;) Just create an onClickListener
/ onTouchListener
to the signature.
If the customer clicks or touches it, the dragging functionality of the Bottomsheet
will be disabled with something like that inside the above mentioned Listener:
final BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
Don't forget to enable the dragging function after the signature isn't clicked or touched anymore. Cheers.
@Lance: This one worked for me: Subscribing to the setOnTouchListener and then changing the isDraggable on touch up/down.
signatureCaptureControl.setOnTouchListener { v, event ->
when (event.action) {
MotionEvent.ACTION_UP -> {
bottomSheetBehavior.isDraggable = true
v.performClick()
}
MotionEvent.ACTION_DOWN -> bottomSheetBehavior.isDraggable = false
}
}