如何使用Edittext和它下面的按钮调整BottomSheet的大小? [英] How to adjust size of BottomSheet with Edittext and button below it?

查看:87
本文介绍了如何使用Edittext和它下面的按钮调整BottomSheet的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to build a BottomSheet to display a view with button and edit text. If I click on the Edittext the Keyboard shows up but it hides the button which is below the edit text. These pics should show my problems

1)普通视图中的"BottomSheet"-第一张图片"

1)BottomSheet in normal view-First Image

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

2)BottomSheet hides the button- Second Image

这是我用于创建BottomSheet的代码

Here is my code for creating 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); 

但是它不起作用.希望能得到一个答案.

but it doesn't work. Would appreciate an answer.

推荐答案

将底部工作表的所有内容都放在滚动视图中,然后尝试.

Put all the content of the bottomsheet in the scrollview and try.

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

这篇关于如何使用Edittext和它下面的按钮调整BottomSheet的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆