BottomSheetDialog
public
class
BottomSheetDialog
extends AppCompatDialog
java.lang.Object
|
↳ |
android.app.Dialog
|
|
↳ |
androidx.activity.ComponentDialog
|
|
|
↳ |
androidx.appcompat.app.AppCompatDialog
|
|
|
|
↳ |
com.google.android.material.bottomsheet.BottomSheetDialog
|
Base class for Dialog
s styled as a bottom sheet.
Edge to edge window flags are automatically applied if the R.attr.navigationBarColor
is transparent or translucent and enableEdgeToEdge
is
true. These can be set in the theme that is passed to the constructor, or will be taken from the
theme of the context (ie. your application or activity theme).
In edge to edge mode, padding will be added automatically to the top when sliding under the
status bar. Padding can be applied automatically to the left, right, or bottom if any of
`paddingBottomSystemWindowInsets`, `paddingLeftSystemWindowInsets`, or
`paddingRightSystemWindowInsets` are set to true in the style.
For more information, see the component
developer guidance and design guidelines.
Summary
Inherited constants |
From interface
android.content.DialogInterface
int |
BUTTON1
|
int |
BUTTON2
|
int |
BUTTON3
|
int |
BUTTON_NEGATIVE
|
int |
BUTTON_NEUTRAL
|
int |
BUTTON_POSITIVE
|
|
Protected constructors |
BottomSheetDialog(Context context, boolean cancelable, DialogInterface.OnCancelListener cancelListener)
|
Inherited methods |
From class
androidx.appcompat.app.AppCompatDialog
void
|
addContentView(View arg0, ViewGroup.LayoutParams arg1)
|
void
|
dismiss()
|
boolean
|
dispatchKeyEvent(KeyEvent arg0)
|
<T extends View>
T
|
findViewById(int arg0)
|
AppCompatDelegate
|
getDelegate()
|
ActionBar
|
getSupportActionBar()
|
void
|
invalidateOptionsMenu()
|
void
|
onCreate(Bundle arg0)
|
void
|
onStop()
|
void
|
onSupportActionModeFinished(ActionMode arg0)
|
void
|
onSupportActionModeStarted(ActionMode arg0)
|
ActionMode
|
onWindowStartingSupportActionMode(ActionMode.Callback arg0)
|
void
|
setContentView(View arg0)
|
void
|
setContentView(int arg0)
|
void
|
setContentView(View arg0, ViewGroup.LayoutParams arg1)
|
void
|
setTitle(CharSequence arg0)
|
void
|
setTitle(int arg0)
|
boolean
|
supportRequestWindowFeature(int arg0)
|
|
From class
androidx.activity.ComponentDialog
void
|
addContentView(View arg0, ViewGroup.LayoutParams arg1)
|
Lifecycle
|
getLifecycle()
|
final
OnBackPressedDispatcher
|
getOnBackPressedDispatcher()
|
SavedStateRegistry
|
getSavedStateRegistry()
|
void
|
initializeViewTreeOwners()
|
void
|
onBackPressed()
|
void
|
onCreate(Bundle arg0)
|
Bundle
|
onSaveInstanceState()
|
void
|
onStart()
|
void
|
onStop()
|
void
|
setContentView(View arg0)
|
void
|
setContentView(int arg0)
|
void
|
setContentView(View arg0, ViewGroup.LayoutParams arg1)
|
|
From class
android.app.Dialog
void
|
addContentView(View arg0, ViewGroup.LayoutParams arg1)
|
void
|
cancel()
|
void
|
closeOptionsMenu()
|
void
|
create()
|
void
|
dismiss()
|
boolean
|
dispatchGenericMotionEvent(MotionEvent arg0)
|
boolean
|
dispatchKeyEvent(KeyEvent arg0)
|
boolean
|
dispatchKeyShortcutEvent(KeyEvent arg0)
|
boolean
|
dispatchPopulateAccessibilityEvent(AccessibilityEvent arg0)
|
boolean
|
dispatchTouchEvent(MotionEvent arg0)
|
boolean
|
dispatchTrackballEvent(MotionEvent arg0)
|
<T extends View>
T
|
findViewById(int arg0)
|
ActionBar
|
getActionBar()
|
final
Context
|
getContext()
|
View
|
getCurrentFocus()
|
LayoutInflater
|
getLayoutInflater()
|
OnBackInvokedDispatcher
|
getOnBackInvokedDispatcher()
|
final
Activity
|
getOwnerActivity()
|
final
SearchEvent
|
getSearchEvent()
|
final
int
|
getVolumeControlStream()
|
Window
|
getWindow()
|
void
|
hide()
|
void
|
invalidateOptionsMenu()
|
boolean
|
isShowing()
|
void
|
onActionModeFinished(ActionMode arg0)
|
void
|
onActionModeStarted(ActionMode arg0)
|
void
|
onAttachedToWindow()
|
void
|
onBackPressed()
|
void
|
onContentChanged()
|
boolean
|
onContextItemSelected(MenuItem arg0)
|
void
|
onContextMenuClosed(Menu arg0)
|
void
|
onCreate(Bundle arg0)
|
void
|
onCreateContextMenu(ContextMenu arg0, View arg1, ContextMenu.ContextMenuInfo arg2)
|
boolean
|
onCreateOptionsMenu(Menu arg0)
|
boolean
|
onCreatePanelMenu(int arg0, Menu arg1)
|
View
|
onCreatePanelView(int arg0)
|
void
|
onDetachedFromWindow()
|
boolean
|
onGenericMotionEvent(MotionEvent arg0)
|
boolean
|
onKeyDown(int arg0, KeyEvent arg1)
|
boolean
|
onKeyLongPress(int arg0, KeyEvent arg1)
|
boolean
|
onKeyMultiple(int arg0, int arg1, KeyEvent arg2)
|
boolean
|
onKeyShortcut(int arg0, KeyEvent arg1)
|
boolean
|
onKeyUp(int arg0, KeyEvent arg1)
|
boolean
|
onMenuItemSelected(int arg0, MenuItem arg1)
|
boolean
|
onMenuOpened(int arg0, Menu arg1)
|
boolean
|
onOptionsItemSelected(MenuItem arg0)
|
void
|
onOptionsMenuClosed(Menu arg0)
|
void
|
onPanelClosed(int arg0, Menu arg1)
|
boolean
|
onPrepareOptionsMenu(Menu arg0)
|
boolean
|
onPreparePanel(int arg0, View arg1, Menu arg2)
|
void
|
onRestoreInstanceState(Bundle arg0)
|
Bundle
|
onSaveInstanceState()
|
boolean
|
onSearchRequested(SearchEvent arg0)
|
boolean
|
onSearchRequested()
|
void
|
onStart()
|
void
|
onStop()
|
boolean
|
onTouchEvent(MotionEvent arg0)
|
boolean
|
onTrackballEvent(MotionEvent arg0)
|
void
|
onWindowAttributesChanged(WindowManager.LayoutParams arg0)
|
void
|
onWindowFocusChanged(boolean arg0)
|
ActionMode
|
onWindowStartingActionMode(ActionMode.Callback arg0)
|
ActionMode
|
onWindowStartingActionMode(ActionMode.Callback arg0, int arg1)
|
void
|
openContextMenu(View arg0)
|
void
|
openOptionsMenu()
|
void
|
registerForContextMenu(View arg0)
|
final
boolean
|
requestWindowFeature(int arg0)
|
final
<T extends View>
T
|
requireViewById(int arg0)
|
void
|
setCancelMessage(Message arg0)
|
void
|
setCancelable(boolean arg0)
|
void
|
setCanceledOnTouchOutside(boolean arg0)
|
void
|
setContentView(int arg0)
|
void
|
setContentView(View arg0, ViewGroup.LayoutParams arg1)
|
void
|
setContentView(View arg0)
|
void
|
setDismissMessage(Message arg0)
|
final
void
|
setFeatureDrawable(int arg0, Drawable arg1)
|
final
void
|
setFeatureDrawableAlpha(int arg0, int arg1)
|
final
void
|
setFeatureDrawableResource(int arg0, int arg1)
|
final
void
|
setFeatureDrawableUri(int arg0, Uri arg1)
|
void
|
setOnCancelListener(DialogInterface.OnCancelListener arg0)
|
void
|
setOnDismissListener(DialogInterface.OnDismissListener arg0)
|
void
|
setOnKeyListener(DialogInterface.OnKeyListener arg0)
|
void
|
setOnShowListener(DialogInterface.OnShowListener arg0)
|
final
void
|
setOwnerActivity(Activity arg0)
|
void
|
setTitle(CharSequence arg0)
|
void
|
setTitle(int arg0)
|
final
void
|
setVolumeControlStream(int arg0)
|
void
|
show()
|
void
|
takeKeyEvents(boolean arg0)
|
void
|
unregisterForContextMenu(View arg0)
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
From interface
androidx.appcompat.app.AppCompatCallback
abstract
void
|
onSupportActionModeFinished(ActionMode arg0)
|
abstract
void
|
onSupportActionModeStarted(ActionMode arg0)
|
abstract
ActionMode
|
onWindowStartingSupportActionMode(ActionMode.Callback arg0)
|
|
From interface
androidx.lifecycle.LifecycleOwner
abstract
Lifecycle
|
getLifecycle()
|
|
From interface
androidx.activity.OnBackPressedDispatcherOwner
abstract
OnBackPressedDispatcher
|
getOnBackPressedDispatcher()
|
|
From interface
androidx.savedstate.SavedStateRegistryOwner
abstract
SavedStateRegistry
|
getSavedStateRegistry()
|
|
From interface
android.content.DialogInterface
abstract
void
|
cancel()
|
abstract
void
|
dismiss()
|
|
From interface
android.view.Window.Callback
abstract
boolean
|
dispatchGenericMotionEvent(MotionEvent arg0)
|
abstract
boolean
|
dispatchKeyEvent(KeyEvent arg0)
|
abstract
boolean
|
dispatchKeyShortcutEvent(KeyEvent arg0)
|
abstract
boolean
|
dispatchPopulateAccessibilityEvent(AccessibilityEvent arg0)
|
abstract
boolean
|
dispatchTouchEvent(MotionEvent arg0)
|
abstract
boolean
|
dispatchTrackballEvent(MotionEvent arg0)
|
abstract
void
|
onActionModeFinished(ActionMode arg0)
|
abstract
void
|
onActionModeStarted(ActionMode arg0)
|
abstract
void
|
onAttachedToWindow()
|
abstract
void
|
onContentChanged()
|
abstract
boolean
|
onCreatePanelMenu(int arg0, Menu arg1)
|
abstract
View
|
onCreatePanelView(int arg0)
|
abstract
void
|
onDetachedFromWindow()
|
abstract
boolean
|
onMenuItemSelected(int arg0, MenuItem arg1)
|
abstract
boolean
|
onMenuOpened(int arg0, Menu arg1)
|
abstract
void
|
onPanelClosed(int arg0, Menu arg1)
|
default
void
|
onPointerCaptureChanged(boolean arg0)
|
abstract
boolean
|
onPreparePanel(int arg0, View arg1, Menu arg2)
|
default
void
|
onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> arg0, Menu arg1, int arg2)
|
abstract
boolean
|
onSearchRequested()
|
abstract
boolean
|
onSearchRequested(SearchEvent arg0)
|
abstract
void
|
onWindowAttributesChanged(WindowManager.LayoutParams arg0)
|
abstract
void
|
onWindowFocusChanged(boolean arg0)
|
abstract
ActionMode
|
onWindowStartingActionMode(ActionMode.Callback arg0)
|
abstract
ActionMode
|
onWindowStartingActionMode(ActionMode.Callback arg0, int arg1)
|
|
From interface
android.view.KeyEvent.Callback
abstract
boolean
|
onKeyDown(int arg0, KeyEvent arg1)
|
abstract
boolean
|
onKeyLongPress(int arg0, KeyEvent arg1)
|
abstract
boolean
|
onKeyMultiple(int arg0, int arg1, KeyEvent arg2)
|
abstract
boolean
|
onKeyUp(int arg0, KeyEvent arg1)
|
|
From interface
android.view.View.OnCreateContextMenuListener
abstract
void
|
onCreateContextMenu(ContextMenu arg0, View arg1, ContextMenu.ContextMenuInfo arg2)
|
|
Public constructors
BottomSheetDialog
public BottomSheetDialog (Context context)
Parameters |
context |
Context |
BottomSheetDialog
public BottomSheetDialog (Context context,
int theme)
Parameters |
context |
Context |
theme |
int |
Protected constructors
BottomSheetDialog
protected BottomSheetDialog (Context context,
boolean cancelable,
DialogInterface.OnCancelListener cancelListener)
Parameters |
context |
Context |
cancelable |
boolean |
cancelListener |
DialogInterface.OnCancelListener |
Public methods
cancel
public void cancel ()
This function can be called from a few different use cases, including Swiping the dialog down
or calling `dismiss()` from a `BottomSheetDialogFragment`, tapping outside a dialog, etc...
The default animation to dismiss this dialog is a fade-out transition through a
windowAnimation. Call ERROR(/#setDismissWithAnimation(true))
if you want to utilize the
BottomSheet animation instead.
If this function is called from a swipe down interaction, or dismissWithAnimation is false,
then keep the default behavior.
Else, since this is a terminal event which will finish this dialog, we override the attached
BottomSheetBehavior.BottomSheetCallback
to call this function, after BottomSheetBehavior.STATE_HIDDEN
is set. This will enforce the swipe down animation before
canceling this dialog.
getDismissWithAnimation
public boolean getDismissWithAnimation ()
Returns if dismissing will perform the swipe down animation on the bottom sheet, rather than
the window animation for the dialog.
getEdgeToEdgeEnabled
public boolean getEdgeToEdgeEnabled ()
Returns if edge to edge behavior is enabled for this dialog.
onAttachedToWindow
public void onAttachedToWindow ()
onDetachedFromWindow
public void onDetachedFromWindow ()
setCancelable
public void setCancelable (boolean cancelable)
Parameters |
cancelable |
boolean |
setCanceledOnTouchOutside
public void setCanceledOnTouchOutside (boolean cancel)
Parameters |
cancel |
boolean |
setContentView
public void setContentView (View view)
setContentView
public void setContentView (int layoutResId)
Parameters |
layoutResId |
int |
setContentView
public void setContentView (View view,
ViewGroup.LayoutParams params)
Parameters |
view |
View |
params |
ViewGroup.LayoutParams |
setDismissWithAnimation
public void setDismissWithAnimation (boolean dismissWithAnimation)
Set to perform the swipe down animation when dismissing instead of the window animation for the
dialog.
Parameters |
dismissWithAnimation |
boolean : True if swipe down animation should be used when dismissing.
|
setLightStatusBar
public static void setLightStatusBar (View view,
boolean isLight)
This method is deprecated.
use EdgeToEdgeUtils.setLightStatusBar(Window, boolean) instead
Parameters |
view |
View |
isLight |
boolean |
Protected methods
onCreate
protected void onCreate (Bundle savedInstanceState)
Parameters |
savedInstanceState |
Bundle |
onStart
protected void onStart ()