3

I am trying to implement the following:

Please check the image here:

enter image description here

The problem is whenever the user taps the compose mail edittext field, the send/save/discard buttons are hidden by the softkeyboard.

Any ideas on how to make those buttons always visible? Thanks.

[EDIT] Finally got it solved!Had to use Linearlayout instead of RelativeLayout and assigning proper layout_weight parameter did the trick. Thanks a lot Femi for pointing out that the buttons need to be outside of the ScrollView.

Here is the final working layout xml in case anyone finds it helpful:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"><ScrollView android:layout_alignParentTop="true" 
    android:layout_weight="1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <RelativeLayout 
        android:id="@+id/InnerRelativeLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
        <EditText 
            android:id="@+id/editTextCompose" 
            android:layout_width="fill_parent"
            android:layout_height="200dp"
            android:gravity="top"
            android:singleLine="false" android:lines="5"
            android:inputType="text"
            android:layout_below="@+id/editTextSubject"
            >
        </EditText>
    </RelativeLayout>
</ScrollView><TableLayout android:id="@+id/recipeButtons" 
    android:background="#B0B0B0" android:padding="3dip" 
    android:stretchColumns="0,1" android:layout_alignParentBottom="true" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <TableRow android:gravity="center"> 
        <Button android:id="@+id/editOtherAdditionButton" 
            android:text="Save" /> 
        <Button android:id="@+id/removeOtherAdditionButton" 
            android:text="Delete" /> 
    </TableRow> 
</TableLayout></LinearLayout>
Saikat
  • 2,613
  • 1
  • 22
  • 14

2 Answers2

0

As documented in @mayra's answer to Android soft keyboard covers edittext field you should see http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft for the details to control.

Modifying the Activity's entry in the AndroidManifest to adjustResize should I think do it.

Community
  • 1
  • 1
Femi
  • 64,273
  • 8
  • 118
  • 148
  • Thanks for your reply Femi. But I already tried adjsutResize, with no luck. – Saikat May 23 '11 at 04:07
  • You might need to wrap your entire app in a ScrollView and then anchor the bottom buttons while making the EditText fill the space. – Femi May 23 '11 at 04:28
  • I am doing that. The RelativeLayout is wrapped within a ScrollView. – Saikat May 23 '11 at 04:40
  • Ah: maybe try `adjustPan`: the spec says **The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.** – Femi May 23 '11 at 04:46
  • You might need to actually change your layout completely like the Email application does: move the buttons OUTSIDE the RelativeLayout. See http://android.git.kernel.org/?p=platform/packages/apps/Email.git;a=blob;f=res/layout/message_compose.xml;h=b29d3ddf4b64bf068a09f1e4969490ceb1d24b79;hb=HEAD – Femi May 23 '11 at 05:19
  • Thanks a lot Femi. I finally figured it out. Incase you are interested I have added the working solution to the question. – Saikat May 23 '11 at 07:13
  • Neat! Will use that myself: had something that I was doing where that really bothered me but simply hadn't gotten around to fixing it. – Femi May 23 '11 at 07:16
0

There is another question about this here, but it looks like the best approach is using the windowSoftInputMode

Community
  • 1
  • 1
Patrick Kafka
  • 9,795
  • 3
  • 29
  • 44