i'm currently trying to implement bottomSheetDialog inside my application. My main activity is composed by a viewpager, a top bar and a bottom navigation bar that i use to switch between fragments. In one of the fragment i'm trying to setup a modal button sheet dialog that have to appear on top of the Main Activity
titleDemo = view.findViewById(R.id.title1);
titleDemo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getContext());
View parentView = getLayoutInflater().inflate(R.layout.dialog, null);
bottomSheetDialog.setContentView(parentView);
bottomSheetDialog.show();
}
});
When i click, the activity behave correctly, fading its colours but nothing shows. For my tests i used a simple layout with some random background color.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightCyan">
</LinearLayout>
I feel that i'm messing with the views but i can't understand how to fix this.
Thanks
you need to add these lines
app:behavior_hideable="true"
app:behavior_peekHeight="120dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
in your LinearLayout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.