I am working with bottom sheet and it is working great if I dont add margin top.
I want the bottom sheet to fill the screen when pulled up but it also goes behind the Action Bar.
To solve this, I added margin top to the bottom sheet equivalent to the height of action bar, it works great until bottom bar is back to bottom.
<RelativeLayout
android:id="@+id/rl_bottom_sheet"
android:layout_width="match_parent"
android:layout_height="280dp"
android:margin_top="60dp"
app:behavior_peekHeight="80dp"
app:behavior_hideable="false"
app:layout_behavior="@string/bottom_sheet_behavior"
android:background="@drawable/ic_camera">
When bottom sheet is slided down, margin is no more there and view above the screen becomes equal to peekHeight + marginTop
Before Expanded
Collapsed after expanding once
The margin-top CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
android:layout_marginTopSpecifies extra space on the top side of this view. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as " 14.5sp ".
Bottom Sheet dialogs seem to be replacing regular Android dialogs and menus. The Bottom Sheet is a component that slides up from the bottom of the screen to showcase additional content in your application. A Bottom Sheet dialog is like a message box triggered by the user's actions.
I can suggest you to change the root layout - from CoordinatorLayout to any other (Relative/Linear and so on). And after that you can add your CoordinatorLayout in your new root ViewGroup with desired marginTop.
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="80dp"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With