Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android BottomSheetDialog can't show title even though I set a title

Tags:

android

It's my very first time to use BottomSheetDialog, the code is like this:

final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
bottomSheetDialog.setTitle("title");
//bottomSheetDialog.setContentView(...)
bottomSheetDialog.show();

When I ran this code, the title didn't show.

Can you explain to me what happened to this code? Thank you ~

like image 466
Veer Avatar asked Jun 27 '16 09:06

Veer


People also ask

What is bottom sheet dialog in Android?

Bottom Sheet dialogs are used in music, payment, and file management applications. In terms of application, any Android view including TextView, ImageView, RecyclerViews, Buttons, and Text inputs can be included in a Bottom Sheet. This makes it quite dynamic.

How to create material design bottom sheet example in Android Studio?

So here is the complete step by step tutorial for Android Material Design Bottom Sheet Example tutorial using design support library android studio. 1. Open your project’s build.gradle ( Module : app ) file. 2. Please add below code inside your build.gradle ( Module : app ) file. 3.

What is difference between bottom sheet View and bottom sheet dialog view?

This view has two different type of views inside it, First one if Bottom Sheet View and second is Bottom Sheet Dialog View. The both view is different from each other because they holds different type of properties.

How do I dismiss a dialog in bottomsheetdialog?

We use bottomSheetDialog.dismiss () to close the dialog once an element is clicked. You can also set a more distinct action, instructing your application to do something when the dialog is dismissed. For instance, the app can launch a new activity. BottomSheetDialogFragment A fragment can be displayed as a Bottom Sheet dialog.


1 Answers

If you look into the source code of android.support.design.widget.BottomSheetDialog you will find, that inside it's constructor there is a line:

// We hide the title bar for any style configuration. Otherwise, there will be a gap
// above the bottom sheet when it is expanded.
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

which clearly states, that Bottom sheet will not have title (with reason). (As of support library version 23.4.0)

Suggestion: Make a title of the view inside the layout of bottom sheet.

like image 80
R. Zagórski Avatar answered Sep 28 '22 06:09

R. Zagórski