Android: How do I prevent the soft keyboard from pushing my view up?

后端 未结 28 1267
南笙
南笙 2020-11-22 05:10

I have a vertical sliding drawer at the bottom of my app. When the soft keyboard opens, it pushes the tab for the drawer up, so it sits atop the keyboard. I actually want it

28条回答
  •  有刺的猬
    2020-11-22 05:49

    You can simply switch your Activity's windowSoftInputModeflag to adjustPan in your AndroidMainfest.xml file inside your activity tag.

    Check the official documentation for more info.

     
    
    

    If your container is not changing size, then you likely have the height set to "match parent". If possible, set the parent to "Wrap Content", or a constraint layout with constraingts to top and bottom of parent.

    The parent container will shrink to fit the available space, so it is likely that your content should be inside of a scolling view to prevent (depending on the phone manufacturer and the layout choosen...)

    1. Content being smashed together
    2. Content hanging off the screen
    3. Content being inacccessable due to it being underneath the keyboard

    even if the layout it is in is a relative or constraint layout, the content could exhibit problems 1-3.

提交回复
热议问题