2011-05-23 17 views
3

我想實現如下:的Android的EditText佈局,如Gmail撰寫屏幕

請查看這裏的形象:

enter image description here

的問題是,每當用戶點擊撰寫郵件的EditText場,發送/保存/放棄按鈕被軟鍵盤隱藏。

有關如何使這些按鈕始終可見的任何想法? 謝謝。

[編輯] 終於解決了!不得不使用LinearLayout而不是RelativeLayout,並指定正確的layout_weight參數。非常感謝Femi指出按鈕需要在ScrollView之外。

這裏是任何人的情況下最終的工作佈局XML發現它有用:

<?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> 

回答

0

由於記錄在@梅拉的回答Android soft keyboard covers edittext field你應該看到http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft的細節控制。

將AndroidManifest中Activity的條目修改爲adjustResize應該這樣做。

+0

感謝您的答覆費米。但我已經嘗試了adjsutResize,沒有運氣。 – Saikat 2011-05-23 04:07:21

+0

您可能需要將整個應用程序包裝在ScrollView中,然後在使EditText填充空間時錨定底部按鈕。 – Femi 2011-05-23 04:28:50

+0

我正在那樣做。 RelativeLayout包裝在ScrollView中。 – Saikat 2011-05-23 04:40:44

0

有關於這here另外一個問題,但它看起來像最好的辦法是使用windowSoftInputMode

+0

看起來像@Femi用相同的答案擊敗我吧 – 2011-05-23 03:59:29

+0

我試過windowSOftInputMode和「adjustResize」選項。它沒有按預期工作。 – Saikat 2011-05-23 04:02:51