Search code examples
javaandroidwindow-soft-input-mode

How to change windowSoftInputMode


I have an Android application, it works. In one activity, I have a simplet EditText and a Button. So when I click on the EditText, the keyboard is showing, but It is on the button. I don't want this, I don't know if is possibile to traslate to top the component when the keyboard is showing.

This is the code of AndroidManifest:

<activity
   android:name="com.bioresult.geopointer.activity.settingActivity"
   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
   android:windowSoftInputMode="stateVisible|adjustResize"
   android:configChanges="orientation|screenSize">            
</activity>

This is thecod of activity:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="#4d4d4d"
    android:gravity="center_horizontal"
    android:baselineAligned="false">

    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_gravity="center_vertical|center_horizontal"
        android:gravity="center_vertical|center_horizontal"
        android:layout_margin="15dp">

        <EditText
           android:id="@+id/editTextPartitaIva" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:hint="@string/nomeAzienda"
           android:lines="1"
           android:singleLine="true"/>   

        <Button 
           android:id="@+id/buttonSalva" 
           android:layout_width="match_parent"
           android:layout_height="40dp"
           android:layout_marginTop="15dp"
           android:textColor="#FFFFFF"
           android:text="@string/salva"
           android:textSize="20sp"
           android:onClick="salva"
           android:background="@drawable/salva_partitaiva_button"
           />
    </LinearLayout>



</LinearLayout>

Solution

  • https://code.google.com/p/android/issues/detail?id=5497

    To avoid it, remove the FullScreen theme of your activity

    From FLAG_FULLSCREEN

    Window flag: hide all screen decorations (such as the status bar) while this window is displayed. This allows the window to use the entire display space for itself -- the status bar will be hidden when an app window with this flag set is on the top layer. A fullscreen window will ignore a value of SOFT_INPUT_ADJUST_RESIZE for the window's softInputMode field; the window will stay fullscreen and will not resize.