33

Consider the following example for a view:

<LinearLayout>
    <EditText />
    <Button />
</LinearLayout>

And in in the manifest file:

android:windowSoftInputMode="adjustPan"

onfocus edittext, the soft keyboard covers a button like so:

enter image description here

but I'd like it like this:

enter image description here

How to scroll view a little more so that the button is visible?

aLearner
  • 1,051
  • 14
  • 30
Airfreshener
  • 826
  • 1
  • 8
  • 18

2 Answers2

15

I just found this post and saw it was unanswered. For the sake of helping others who may come use this in the manifest for activity

android:windowSoftInputMode="stateUnchanged|adjustResize"

try just one and see if that suits your needs.

Good luck

RorschachDev
  • 354
  • 4
  • 11
  • 2
    I must've tried 30 different combinations for windowSoftInputMode before finding this post. Thank you. – android_student Dec 20 '14 at 21:14
  • 3
    "stateUnchanged|adjustResize" will resize the window, and attempt to keep the currently focused item on screen. It will make no effort to keep the buttons on screen. – Brian Attwell Jun 08 '15 at 18:58
  • @DotProductSoft In which section of Manifest should be the property ? – Tomasz Waszczyk Aug 24 '15 at 10:27
  • Sorry. Only noticed your question today. You probably have found the answer, but hopefully others can use this information. Put it in the manifest as an attribute of the tag that you are presenting. – RorschachDev Sep 23 '15 at 17:38
  • How do you recreate this dynamically.I know this: getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); But how do you tell it stateUnchanged? – KasparTr Apr 17 '16 at 08:10
  • KasparTr - Sorry I'm not sure what you mean. – RorschachDev Apr 21 '16 at 01:41
  • KasparTr - Try bitwise "OR" WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN – RorschachDev Apr 21 '16 at 01:51
-3

Can you add an empty RelativeLayout below the buttons. set its android:layout_height="50dp" or any value that satisfy your need. And use a ScrollView, notice that ScrollView can only have 1 child layout.

<ScrollView >
  <LinearLayout>
    <EditText />
    <Button />
    <RelativeLayout 
      android:layout_height="50dp"
      android:layout_width="match_parent" />
  </LinearLayout>
</ScrollView>
ogramus
  • 21
  • 10