1

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.

enter image description here

enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

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

<ScrollView layout_behavior = "@string/bottom_sheet....">
<your layout/>
<ScrollView>
Pratik Mhatre
  • 779
  • 7
  • 12
  • If it still don't work, you should try wrapping whole content inside a scrollview. Scrollview works great in such cases. – Pratik Mhatre Jun 22 '18 at 07:37
  • i already did this. But i won't work. Any other idea. Maybe you could post an example for me – android_developer Jun 22 '18 at 07:52
  • Btw what do you mean with "layout_behavior ="@string/bottom_sheet" in your first answer? – android_developer Jun 22 '18 at 07:56
  • The problem why your dialog not responding to ui changes may have occurred due to dialog. You can try using "Persistent Bottomsheet" instead of BottomsheetDialog – Pratik Mhatre Jun 22 '18 at 08:35
  • okay, but isn't there any solution to my problem. You said something about the layout behavior in your first answer. But what string should I use there? – android_developer Jun 22 '18 at 09:23
  • Yes, the layout_behavior tag is used in case of persistent bottomsheets, in such cases your bottomsheet is the part of your parent layout, but assigned with the spacial tag "layout_behavior". By setting this tag, you declare a layout as bottomsheet. Later you can control its state by using BottomsheetBehavior in code. As it is part of your parent layout, it responds to UI changes efficiently than dialogs. Also, note that whole of your layout content should be wrapped inside CoordinaterLayout – Pratik Mhatre Jun 22 '18 at 09:51