首页 > 解决方案 > 对话框按钮 kotlin

问题描述

我以网站https://www.simplifiedcoding.net/bottom-sheet-android/为例

回购这个项目-> https://github.com/probelalkhan/BottomSheet-Tutorial

现在我有问题在此处输入图像描述(见问题) 展开和滚动对话框 正如你所见,模态对话框没有完全打开(它可以滚动并展开到全屏),但我需要完全打开对话框。你可以告诉我如何实现它。

我很高兴听到你的回答。

更新

我注意到这个问题发生在平板电脑上。有没有办法解决这个问题?

标签: androidkotlin

解决方案


材料设计指南说,底部表应该在底部表上方区域为 19:6 的高度处窥视。由于您的横向屏幕比 16:9 短,因此它会窥视规范中的最小高度。

您可以像这样自定义窥视高度:

<style name="Theme.YourApp" parent="Theme.Design">
    <!-- other style configs -->
    <item name="bottomSheetDialogTheme">@style/GiveItSomeName</item>
</style>

<style name="GiveItSomeName" parent="Theme.Design.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/BottomSheetStyle</item>
</style>

<style name="BottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
    <item name="app:peekHeight">256dp</item><!-- ***** The initial height you want ***** -->
</style>

在 res -> values -> styles 中的 styles.xml 中添加上面的布局

在 bottom_sheet_modal.xml 中进行另一项更改(添加背景)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@color/white"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/listViewOptions"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>

在colors.xml中添加白色


推荐阅读