How to adjust size of BottomSheet with Edittext and button below it?

♀尐吖头ヾ 提交于 2019-12-14 03:58:12

问题


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 in normal view-First Image

2)BottomSheet hides the button- Second Image

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);

I also added a specific style

<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">

i also tried to change the behavior with

addNewListBottomSheet.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

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


回答1:


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

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


来源:https://stackoverflow.com/questions/50970023/how-to-adjust-size-of-bottomsheet-with-edittext-and-button-below-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!