BottomSheetDialog\'s background is blinking when switching between apps. What am I doing wrong ?
MainActivity.java
public class MainActi
Use Coordinate layout instead of constraint layout, and define bottomsheet layout in xml like below
In Java Class Use like this.
private BottomSheetBehavior mBottomSheetBehavior;
private View bottomSheet;
private isBottomSheetExpand = false;
...
btn1.setOnClickListner(new View.OncliView.OnClickListener(){
@Override
public void onClick(View v) {
if(isBottomSheetExpand){
openBottomSheet();
}else{
closeBottomSheet();
}
}
});
...
public void closeBottomSheet() {
if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
isBottomSheetExpand = false;
}
}
public void openBottomSheet() {
if (mBottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
isBottomSheetExpand = true;
}
}