arjoan
arjoan

Reputation: 1849

Make a layout containing editText and buttons sit above the keyboard

I have a layout which contains a an EditText and Button at the bottom of the screen. Above this is a ListView. I want the EditText and button visible when the keyBoard pops up. But this is not hapening inspite of giving windowSoftInputMode="adjustResize"

Below is my Layout:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/recents_header_bg"
    android:padding="2dp" >

    <TextView
        android:id="@+id/tv_msg_header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Name"
        android:textColor="@color/white1"
        android:textSize="15sp" />

    <Button
        android:id="@+id/bt_msg_cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="@drawable/bt_call_log"
        android:text="Cancel"
        android:textColor="@color/white1" />
</RelativeLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="center"
    android:layout_weight="1" >

    <ListView
        android:id="@+id/lv_msg_thread_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:cacheColorHint="#00000000"
        android:divider="@color/recents_list_seperator"
        android:dividerHeight="1dp"
        android:duplicateParentState="true"
        android:fadingEdge="none"
        android:fastScrollEnabled="true" >
    </ListView>

    <TextView
        android:id="@+id/tv_msg_error"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:visibility="gone" />
</FrameLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/grey05"
    android:orientation="vertical"
    android:padding="1dp" >

    <EditText
        android:id="@+id/et_msg_entry"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:gravity="top"
        android:hint="Type your message here" />

    <Button
        android:id="@+id/bt_msg_send"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:background="@drawable/bt_call_log"
        android:text="Send"
        android:textColor="@color/white1" />
</LinearLayout>

Also in my mainfest options given for the activity is:

<activity
        android:name=".ui.MessageActivity"
        android:screenOrientation="portrait" 
        android:windowSoftInputMode="stateHidden|adjustResize"
        android:exported="false"/>

IS there any way to get this done?. Like in the default messaging app

Upvotes: 3

Views: 1249

Answers (1)

Kevin Coppock
Kevin Coppock

Reputation: 134664

Your LinearLayout orientation should be horizontal, not vertical.

Upvotes: 1

Related Questions