@@ -71,24 +71,23 @@ class MainActivity : AppCompatActivity() {
7171}
7272```
7373
74- More info on each individual section below.
74+ More information on each individual section, below.
7575
7676### Setting behavior
7777
7878There are several attributes that can be used to adjust the behavior of both
7979standard and modal bottom sheets.
8080
81- In standard bottom sheets, they can be applied in xml by setting them on the
82- same child ` View ` that has the ` app:layout_behavior ` set on it, or
83- programmaticaly like so:
81+ Behavior attributes can be applied to standard bottom sheets in xml by setting
82+ them on a child ` View ` set to ` app:layout_behavior ` , or programmatically:
8483
8584``` kt
8685val standardBottomSheetBehavior = BottomSheetBehavior .from(standardBottomSheet)
8786// Use this to programmatically apply behavior attributes
8887```
8988
90- In modal bottom sheets they can be applied via app-level theme attributes and
91- styles:
89+ Behavior attributes can be applied to modal bottom sheets using app-level theme
90+ attributes and styles:
9291
9392``` xml
9493<style name =" ModalBottomSheet" parent =" Widget.Material3.BottomSheet.Modal" >
@@ -104,15 +103,15 @@ styles:
104103</style >
105104```
106105
107- Or programmaticaly like so :
106+ Or programmatically :
108107
109108``` kt
110109val modalBottomSheetBehavior = (modalBottomSheet.dialog as BottomSheetDialog ).behavior
111110// Use this to programmatically apply behavior attributes
112111```
113112
114- More info about these attributes and their default values in the
115- [ behavior attributes] ( #behavior-attributes ) section.
113+ More information about these attributes and their default values is available in
114+ the [ behavior attributes] ( #behavior-attributes ) section.
116115
117116### Retaining behavior on configuration change
118117
@@ -127,13 +126,13 @@ OR operations):
127126* ` SAVE_ALL ` : All aforementioned attributes are preserved.
128127* ` SAVE_NONE ` : No attribute is preserved. This is the default value.
129128
130- That can be done in code like so :
129+ Behaviors can also be set in code:
131130
132131``` kt
133132bottomSheetBehavior.saveFlags = BottomSheetBehavior .SAVE_ALL
134133```
135134
136- Or in xml via the ` app:behavior_saveFlags ` attribute.
135+ Or in xml using the ` app:behavior_saveFlags ` attribute.
137136
138137### Setting state
139138
@@ -144,18 +143,18 @@ Standard and modal bottom sheets have the following states:
144143 should have enough height to indicate there is extra content for the user to
145144 interact with.
146145* ` STATE_EXPANDED ` : The bottom sheet is visible at its maximum height and it
147- is neither dragging or settling (see below).
146+ is neither dragging nor settling (see below).
148147* ` STATE_HALF_EXPANDED ` : The bottom sheet is half-expanded (only applicable if
149- ` behavior_fitToContents ` has been set to false), and is neither dragging or
148+ ` behavior_fitToContents ` has been set to false), and is neither dragging nor
150149 settling (see below).
151150* ` STATE_HIDDEN ` : The bottom sheet is no longer visible and can only be
152151 re-shown programmatically.
153152* ` STATE_DRAGGING ` : The user is actively dragging the bottom sheet up or down.
154- * ` STATE_SETTLING ` : The bottom sheet is settling to specific height after a
153+ * ` STATE_SETTLING ` : The bottom sheet is settling to a specific height after a
155154 drag/swipe gesture. This will be the peek height, expanded height, or 0, in
156155 case the user action caused the bottom sheet to hide.
157156
158- You can set a state on the bottom sheet like so :
157+ You can set a state on the bottom sheet:
159158
160159``` kt
161160bottomSheetBehavior.state = BottomSheetBehavior .STATE_COLLAPSED
@@ -165,7 +164,7 @@ bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
165164
166165### Listening to state and slide changes
167166
168- A ` BottomSheetCallback ` can be added to a ` BottomSheetBehavior ` like so :
167+ A ` BottomSheetCallback ` can be added to a ` BottomSheetBehavior ` :
169168
170169``` kt
171170val bottomSheetCallback = object : BottomSheetBehavior .BottomSheetCallback () {
@@ -190,43 +189,41 @@ bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallback)
190189
191190` BottomSheetBehavior ` can automatically handle insets (such as for
192191[ edge to edge] ( https://developer.android.com/training/gestures/edge-to-edge ) ) by
193- specifying any of:
192+ specifying any of these to true on the view :
194193
195194* ` app:paddingBottomSystemWindowInsets `
196195* ` app:paddingLeftSystemWindowInsets `
197196* ` app:paddingRightSystemWindowInsets `
198197* ` app:paddingTopSystemWindowInsets `
199198
200- to true on the view.
201-
202199On API 21 and above the modal bottom sheet will be rendered fullscreen (edge to
203200edge) if the navigation bar is transparent and ` app:enableEdgeToEdge ` is true.
204201
205- It can automatically add insets if any of the padding attributes above are set
202+ Insets can be added automatically if any of the padding attributes above are set
206203to true in the style, either by updating the style passed to the constructor, or
207204by updating the default style specified by the ` ?attr/bottomSheetDialogTheme `
208205attribute in your theme.
209206
210207` BottomSheetDialog ` will also add padding to the top when the bottom sheet
211- slides under the status bar to prevent content from being drawn underneath it.
208+ slides under the status bar, to prevent content from being drawn underneath it.
212209
213210### Making bottom sheets accessible
214211
215212The contents within a bottom sheet should follow their own accessibility
216- guidelines, such as images having content descriptions set on them .
213+ guidelines, such as setting content descriptions for images .
217214
218215## Standard bottom sheet
219216
220217Standard bottom sheets co-exist with the screen’s main UI region and allow for
221218simultaneously viewing and interacting with both regions. They are commonly used
222- to keep a feature or secondary content visible on screen when content in main UI
223- region is frequently scrolled or panned.
219+ to keep a feature or secondary content visible on screen when content in the
220+ main UI region is frequently scrolled or panned.
224221
225222` BottomSheetBehavior ` is applied to a child of
226223[ CoordinatorLayout] ( https://developer.android.com/reference/androidx/coordinatorlayout/widget/CoordinatorLayout )
227224to make that child a ** persistent bottom sheet** , which is a view that comes up
228225from the bottom of the screen, elevated over the main content. It can be dragged
229- vertically to expose more or less of their content.
226+ vertically to expose more or less content.
230227
231228API and source code:
232229
@@ -237,7 +234,7 @@ API and source code:
237234### Standard bottom sheet example
238235
239236The following example shows a standard bottom sheet in its collapsed and
240- expanded state :
237+ expanded states :
241238
242239![ Standard bottom sheet example. Collapsed on the left and expanded on the
243240right.] ( assets/bottomsheet/bottomsheet_standard.png )
@@ -246,8 +243,7 @@ right.](assets/bottomsheet/bottomsheet_standard.png)
246243display content on a bottom sheet, perform enter/exit animations, respond to
247244dragging/swiping gestures, etc.
248245
249- Apply the ` BottomSheetBehavior ` to a direct child ` View ` of ` CoordinatorLayout `
250- like so:
246+ Apply the ` BottomSheetBehavior ` to a direct child ` View ` of ` CoordinatorLayout ` :
251247
252248``` xml
253249<androidx .coordinatorlayout.widget.CoordinatorLayout
@@ -290,22 +286,23 @@ like so:
290286</androidx .coordinatorlayout.widget.CoordinatorLayout>
291287```
292288
293- In this example, the bottom sheet is in fact the ` FrameLayout ` .
289+ In this example, the bottom sheet is the ` FrameLayout ` .
294290
295291## Modal bottom sheet
296292
297293Modal bottom sheets present a set of choices while blocking interaction with the
298294rest of the screen. They are an alternative to inline menus and simple dialogs
299- on mobile, providing additional room for content, iconography, and actions.
295+ on mobile devices, providing additional room for content, iconography, and
296+ actions.
300297
301298` BottomSheetDialogFragment ` is a thin layer on top of the regular support
302299library Fragment that renders your fragment as a ** modal bottom sheet** ,
303300fundamentally acting as a dialog.
304301
305- Modal bottom sheets render a shadow on the content below them to indicate that
306- they are modal. If the content outside of the dialog is tapped then the bottom
307- sheet is dismissed. Modal bottom sheets can be dragged vertically and dismissed
308- by completely sliding them down.
302+ Modal bottom sheets render a shadow on the content below them, to indicate that
303+ they are modal. If the content outside of the dialog is tapped, the bottom sheet
304+ is dismissed. Modal bottom sheets can be dragged vertically and dismissed by
305+ sliding them down completely .
309306
310307API and source code:
311308
@@ -316,7 +313,7 @@ API and source code:
316313### Modal bottom sheet example
317314
318315The following example shows a modal bottom sheet in its collapsed and expanded
319- state :
316+ states :
320317
321318![ Modal bottom sheet example. Collapsed on the left and expanded on the right.] ( assets/bottomsheet/bottomsheet_modal.png )
322319
@@ -350,7 +347,7 @@ modalBottomSheet.show(supportFragmentManager, ModalBottomSheet.TAG)
350347you need to use ` Activity.getSupportFragmentManager() ` .
351348
352349** Note:** Don't call ` setOnCancelListener ` or ` setOnDismissListener ` on a
353- ` BottomSheetDialogFragment ` , instead you can override
350+ ` BottomSheetDialogFragment ` . You can override
354351` onCancel(DialogInterface) ` or ` onDismiss(DialogInterface) ` if necessary.
355352
356353## Anatomy and key properties
@@ -396,15 +393,15 @@ Attribute | Related method(s) | Default value
396393
397394### Styles
398395
399- Element | ** Default value**
396+ ** Element** | ** Default value**
400397------------------------- | -------------------------------------------
401398** Default style (modal)** | ` @style/Widget.Material3.BottomSheet.Modal `
402399
403400Default style theme attribute:` ?attr/bottomSheetStyle `
404401
405402### Theme overlays
406403
407- Element | ** Theme overlay**
404+ ** Element** | ** Theme overlay**
408405------------------------- | ------------------------------------------
409406** Default theme overlay** | ` ThemeOverlay.Material3.BottomSheetDialog `
410407
419416## Theming bottom sheets
420417
421418Bottom sheets support
422- [ Material Theming] ( https://material.io/components/sheets-bottom#theming ) and can
423- be customized in terms of color and shape.
419+ [ Material Theming] ( https://material.io/components/sheets-bottom#theming ) , which
420+ can customize color and shape.
424421
425422### Bottom sheet theming example
426423
@@ -472,9 +469,10 @@ In `res/values/styles.xml`:
472469```
473470
474471** Note:** The benefit of using a custom ` ThemeOverlay ` is that any changes to
475- your main theme, such as updated colors, will be reflected in the bottom sheet
476- ( as long as they're not overridden in your custom theme overlay) . If you use a
477- custom ` Theme ` instead ( by extending from one of the
478- ` Theme.Material3.*.BottomSheetDialog ` variants) you have more control over
472+ your main theme, such as updated colors, will be reflected in the bottom sheet,
473+ as long as they're not overridden in your custom theme overlay. If you use a
474+ custom ` Theme ` instead, by extending from one of the
475+ ` Theme.Material3.*.BottomSheetDialog ` variants, you will have more control over
479476exactly what attributes are included in each, but it also means you'll have to
480- duplicate any changes that you've made in your main theme into these as well.
477+ duplicate any changes that you've made in your main theme into your custom
478+ theme.
0 commit comments