Android windowSoftInputMode=“adjustPan” scroll som

2020-02-23 06:00发布

问题:

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:

but I'd like it like this:

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

回答1:

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



回答2:

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>