问题
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