我使用底页对话框,但它无法自动展开其全尺寸,我必须向上拖动它!
如何设置显示整个对话框高度的修正大小?
这是我的代码:
主要活动:
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>
答案 0 :(得分:1)
您可以使用app:behavior_peekHeight
和app: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>