【问题标题】:bottom sheet dialog height底部工作表对话框高度
【发布时间】:2018-05-14 22:33:04
【问题描述】:

我使用底部工作表对话框,但它无法自动展开完整大小,我必须向上拖动它!

如何设置显示整个对话框的高度的固定大小?

这是我的代码:

主要活动:

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>

【问题讨论】:

    标签: android kotlin


    【解决方案1】:

    您可以使用app:behavior_peekHeightapp:behavior_hideable,例如:

    <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>
    

    【讨论】:

      猜你喜欢
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-25
      • 1970-01-01
      • 2018-09-22
      相关资源
      最近更新 更多