开发者

Android EditText Layout like Gmail Compose Screen

开发者 https://www.devze.com 2023-03-07 12:37 出处:网络
I am trying to implement the following: Please check the image here: The problem is whenever the user taps the compose mail edittext field, the sen开发者_如何学Pythond/save/discard buttons are hi

I am trying to implement the following:

Please check the image here:

Android EditText Layout like Gmail Compose Screen

The problem is whenever the user taps the compose mail edittext field, the sen开发者_如何学Pythond/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>


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号