user8882642
user8882642

Reputation:

bottom sheet dialog height

I use bottom sheet dialog but it cant expand automatically in its full size, and i have to drag up it!

how I can set a fix size for its height that show whole of dialog?

this is my code:

main activity:

bottomSheetView = layoutInflater.inflate(R.layout.dialog_bottom_sheet, null)
bottomSheetDialog.setContentView(bottomSheetView)
val bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetView.parent as View)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
bottomSheetDialog.show()

dialog_bottom_sheet:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeLayoutBottomSheetView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#f9626263"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
    tools:context=".view.activity.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/background_bottom_sheet_dialog"
        android:orientation="vertical">

        <View
            android:id="@+id/backgroundViewDialog"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:padding="20dp"
            tools:ignore="UselessParent">
        </LinearLayout>
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

Upvotes: 1

Views: 2395

Answers (1)

Ahmed Abidi
Ahmed Abidi

Reputation: 1077

you can use app:behavior_peekHeight and app:behavior_hideable, in your case for example :

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeLayoutBottomSheetView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#f9626263"
    app:behavior_hideable="false"
    app:behavior_peekHeight="100dp"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
    tools:context=".view.activity.MainActivity">

</android.support.v4.widget.NestedScrollView>

Upvotes: 1

Related Questions