Osc*_*tor 2 android tablet android-studio bottom-sheet android-bottomsheetdialog
我在我的应用程序中实现了 BottomSheetDialog,但是当我将其安装在平板电脑上并将平板电脑放下时,第一次单击时它不会完全展开。它首先展开到“折叠”状态,您必须将其向上拖动才能看到所有内容。为什么要这样做?您可以根据自己的风格更改某些设置吗?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
app:behavior_peekHeight="0dp"
>
...
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
val view = layoutInflater.inflate(R.layout.home_bottom_sheet_dialog, null)
val bottomSheetDialog = BottomSheetDialog(activity!!)
bottomSheetDialog.setContentView(view)
bottomSheetDialog.show()
Run Code Online (Sandbox Code Playgroud)
我将 API 22 AndroidX 与 kotlin 结合使用。
正如Sinan Ceylan所说,这部分布局是不需要的。
应用程序:layout_behavior =“com.google.android.material.bottomsheet.BottomSheetBehavior”应用程序:behavior_peekHeight =“0dp”
但为了解决我的问题,我在显示之前将 BottomSheetBehavior 的PeakHeight变量设置为较大的值。
bottomSheetDialog.setContentView(view)
bottomSheetDialog.behavior.peekHeight = 1000
bottomSheetDialog.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5156 次 |
| 最近记录: |