I have activity in android where there is an edit box and 3 buttons below the edit box. Please pay attention to the attached file. When this action is run, the default state is STATE1 (see Image). By default, the keyboard is visible. Now, when I press the back button or delete the keyboard, I want the edittext to resize to fit the entire screen, as shown in STATE2.
I am not sure how to do this. I have an edittext hardcoded height for some dp based on the target device. I believe that this needs to be changed. Can anyone help me on how to do this.
XML layout file below as well as screencap
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <EditText android:id="@+id/EditMessage" android:layout_width="fill_parent" android:layout_height="150dp" android:background="@drawable/newback" android:gravity="top" android:imeOptions="actionDone" android:inputType="textMultiLine|textFilter|textVisiblePassword|textNoSuggestions" android:maxLength="200" android:padding="5dp" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#000000" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" > <Button android:id="@+id/PostMessage" android:layout_width="0dp" android:layout_height="45dp" android:layout_weight="1" android:layout_marginRight="0.2dp" android:background="@drawable/newbutton_corner" android:text="@string/SubmitMessage" android:textColor="#FFFFFF" android:textStyle="bold" /> <Button android:id="@+id/CancelMessage" android:layout_width="0dp" android:layout_height="45dp" android:layout_weight="1" android:layout_marginRight="0.2dp" android:background="@drawable/newbutton_corner" android:text="@string/CancelMessage" android:textColor="#FFFFFF" android:textStyle="bold" /> <Button android:id="@+id/DeleteMessage" android:layout_width="0dp" android:layout_height="45dp" android:layout_weight="1" android:background="@drawable/newbutton_corner" android:text="@string/DeleteMessage" android:textColor="#FFFFFF" android:textStyle="bold" /> </LinearLayout> </LinearLayout> </RelativeLayout>

source share