BottomSheetDialogFragment jumps on top of status bar, when change view's visibility and focus an EditText

757 views Asked by At

I have a BottomSheetDialogFragment in my project. Because of some special requirements when the input value is a number I have to use a custom keyboard (Custom View). When focus editText, I hide the system keyboard and change the visibility of the custom keyboard from GONE to VISIBLE. However, I have a very annoying problem. when the focus edittext bottom sheet jumps up and sticks to the status bar, and the overlay is pushed back down. Since the project is quite large, I think there are some places where there may be conflicts, I have created a new project but not having the problem mentioned again. So I was wondering if anyone has had the same problem as me, and can suggest me some ways to solve it. Thanks.

Image describes my problem

Expected result Does anyone had the same problem or any idea how to fix this strange jumps

UPDATE: the solution is remove animateLayoutChange attributes in layout XML file.

1

There are 1 answers

1
Sasha Arutyunyan On

Try this

Styles:

<style name="BottomSheetDialogThemeNoFloating" parent="Theme.Design.Light.BottomSheetDialog">
        <item name="android:windowIsFloating">false</item>
        <item name="android:windowSoftInputMode">adjustResize</item>
</style>

Add this in the dialog

override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_add_or_edit_product, container, false)