【问题标题】:How to adjust size of BottomSheet with Edittext and button below it?如何使用 Edittext 和下方的按钮调整 BottomSheet 的大小?
【发布时间】:2018-11-30 20:58:45
【问题描述】:

我想构建一个 BottomSheet 来显示带有按钮的视图并编辑文本。如果我单击 Edittext,则会显示键盘,但它会隐藏编辑文本下方的按钮。 这些照片应该显示我的问题

1)BottomSheet in normal view-First Image

2)BottomSheet 隐藏按钮-第二张图片

这是我创建BottomSheet的代码

addNewListBottomSheet = new BottomSheetDialog(this, R.style.BottomSheetDialogTheme);
        View bottomSheetRootView = getLayoutInflater().inflate(R.layout.addnewlist_bottomsheet_layout, null);
        addNewListBottomSheet.setContentView(bottomSheetRootView);

我还添加了特定样式

<style name="BottomSheet" parent="@style/Widget.Design.BottomSheet.Modal">
    <item name="android:background">@drawable/bottomsheet_round_bg</item>
</style>

<style name="BaseBottomSheetDialog" parent="@style/Theme.Design.Light.BottomSheetDialog">
    <item name="android:windowIsFloating">true</item>
    <item name="bottomSheetStyle">@style/BottomSheet</item>
</style>

<style name="BottomSheetDialogTheme" parent="BaseBottomSheetDialog">

我也尝试用

改变行为
addNewListBottomSheet.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

但它不起作用。希望得到答复。

【问题讨论】:

    标签: android button android-edittext dialog bottom-sheet


    【解决方案1】:

    将bottomsheet的所有内容放到scrollview中试试。

    <ScrollView layout_behavior = "@string/bottom_sheet....">
    <your layout/>
    <ScrollView>
    

    【讨论】:

    • 如果它仍然不起作用,您应该尝试将整个内容包装在滚动视图中。 Scrollview 在这种情况下效果很好。
    • 我已经这样做了。但我不会工作。任何其他想法。也许您可以为我发布一个示例
    • 顺便说一句,您的第一个答案中的“layout_behavior ="@string/bottom_sheet" 是什么意思?
    • 您的对话框没有响应ui更改的问题可能是由于对话框引起的。您可以尝试使用“Persistent Bottomsheet”而不是 BottomsheetDialog
    • 好的,但是我的问题没有任何解决方案。您在第一个答案中谈到了布局行为。但是我应该在那里使用什么字符串?
    猜你喜欢
    • 2011-03-08
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    • 2013-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-19
    相关资源
    最近更新 更多