Hossein POURAKBAR
Hossein POURAKBAR

Reputation: 1181

Android hidden layout buttons behind soft keyboard

I'm developing an application which needs user enter some words into. But as soon as keyboard opening my layout buttons in bottom of layout remain behind soft keyboard.

My app is here

enter image description here

I need my buttons remains showing when soft keyboard opening.

enter image description here

Here is my layout resource file:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d3d3d3" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="top"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/llWord"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/lblWord"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="5dp"
            android:text="@string/string_word"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#555555" />

        <EditText
            android:id="@+id/txtWord"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:ems="10"
            android:hint="@null"
            android:text="@null"
            android:textColor="#000000" >
        </EditText>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/llInfo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/lblInfo"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="5dp"
            android:text="@null"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#555555" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/llMeaning"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="20dp" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="5dp"
            android:text="@string/string_meaning"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#555555" />

        <EditText
            android:id="@+id/txtMeaning"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:ems="10"
            android:hint="@null"
            android:text="@null"
            android:textColor="#000000" >
        </EditText>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/llSynonyms"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="5dp"
            android:text="@string/string_synonyms"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#555555" />

        <EditText
            android:id="@+id/txtSynonyms"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:ems="10"
            android:hint="@null"
            android:text="@null"
            android:textColor="#000000" >
        </EditText>
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/btnShow"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginRight="0.5dp"
        android:layout_weight="1"
        android:background="@drawable/btn"
        android:drawableLeft="@drawable/ic_action_undo"
        android:paddingLeft="15dp"
        android:text="@string/action_show"
        android:textColor="#d3d3d3" />

    <Button
        android:id="@+id/btnTrue"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginRight="0.5dp"
        android:layout_weight="1"
        android:background="@drawable/btn"
        android:drawableLeft="@drawable/ic_action_accept"
        android:paddingLeft="15dp"
        android:text="@string/action_true"
        android:textColor="#d3d3d3" />

    <Button
        android:id="@+id/btnFalse"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/btn"
        android:drawableLeft="@drawable/ic_action_remove"
        android:paddingLeft="15dp"
        android:text="@string/action_false"
        android:textColor="#d3d3d3" />
</LinearLayout>

Upvotes: 1

Views: 961

Answers (1)

Rey Pham
Rey Pham

Reputation: 605

Go to AndroidManifest.xml , add this to your Activity declare:

android:windowSoftInputMode="adjustResize"

Upvotes: 1

Related Questions