2

I have following layout:

<LinearLayout
    android:id="@+id/linearLayoutHolder"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:background="@android:color/white" >

    <EditText android:id="@+id/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:inputType="textCapSentences"
        android:background="@android:color/transparent"
        android:hint="@string/edit_message"
        android:textColorHint="@android:color/darker_gray"
        android:windowSoftInputMode="stateHidden"/>

</LinearLayout>

This produces:

enter image description here

Now, when user presses the show background apps button at the bottom (as shown in above picture), and when user comes back to the app, the soft keyboard gets shown.

enter image description here

I don't want the soft keyboard to be shown in this case.

How can this be done?

user5155835
  • 4,392
  • 4
  • 53
  • 97

1 Answers1

9

In your AndroidManifest.xml, add the below attribute for the entry of this Activity:

android:windowSoftInputMode="stateHidden"

It is not supposed to be written in your layout XML, but the AndroidManifest.xml.

To set more than one soft input modes, you can set it like:

android:windowSoftInputMode="stateHidden|adjustResize"

For more information, you can refer the documentation.

Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55