Fixed background, no resizing on keyboard

Asked

Viewed 126 times

2

I have the following layout for color, set in background of LinearLayout:

background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="270"
        android:centerColor="#7cf1db"
        android:endColor="#831f51"
        android:startColor="#038068"
        android:type="linear" />
</shape>

Upshot:

Background1

But when you select an Edittext and the keyboard triggered, the background color "goes up":

Background2

I would like to leave this background fixed, without this "resizing" when opening the keyboard.

1 answer

2


For the keyboard not to modify its layout, use the following flag in your file Manifest.xml:

<activity android:windowSoftInputMode="adjustPan">

adjustPan - The main window of the activity is not resized to create space for the on-screen software keyboard. Instead, you move the contents of the window automatically so that the current focus is never overlaid by the keyboard and users can always see what they type. Typically, this behavior is less desirable than resizing, as the user may need to close the software keyboard to access and interact with the overlapping parts of the window.

Look at this and others flags for the keyboard on official documentation.

  • 1

    It worked ! Just complementing, would have to put in all <activity> manifest or there is a way that aggregates in all ?

  • You can put the same code between the tags <application>. Something like that: <application android:windowSoftInputMode="adjustPan" </application>

  • In the <application> didn’t work no.

  • Really, looking at the possible tag flags <application>, to windowSoftInputMode is not found. So the expected way is to include in all your <activity>.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.