The initial visibility of the initial bottom sheet of Android

I am trying to implement a permanent bottom sheet in my layout - one that cannot be completely hidden, but always peeps from below and can be expanded to full height. This is my layout:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical">

        <!-- main content -->

    </LinearLayout>

    <LinearLayout
        android:id="@+id/layoutBottomSheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center|bottom"
        android:background="@drawable/custom_background"
        android:clipToPadding="false"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        app:behavior_hideable="false"
        app:behavior_peekHeight="50dp"
        app:layout_behavior="@string/bottom_sheet_behavior">

        <!-- bottom sheet content -->

    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>

I expect the bottom sheet to be visible and collapse as soon as I land on the screen, but it is not hidden. I can make it appear by calling bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_EXPANDED)in onCreate(). This, oddly enough, only slightly expands it - more than the drop-in height, but less than the total height that it should occupy. After it appears in this state, I can drag it up and down to where it should be, and it works fine. The problem is that the initial landing on the screen is damaged.

, , Bottom Sheet . ?

+4
1

- , . android:layout_gravity="center|bottom" . , .

0

Source: https://habr.com/ru/post/1682390/


All Articles