2011-03-10 88 views
0

我正在完成實現一個應用程序,其中有內部活動發送消息(只需editText和兩個按鈕 - 發送和取消,消息然後發送到固定地址)。當我開始這個活動時,在屏幕上我看到文本框和鍵盤,它立即顯示。但是這樣做的缺點是這些按鈕被鍵盤覆蓋或半覆蓋,我想要的是與消息中的類似。當鍵盤可見時,縮小文本字段並在鍵盤上方的添加按鈕中顯示,如果我在屏幕下方回擊箭頭,則鍵盤消失,幾乎整個屏幕將由此editText拍攝,底部將出現這兩個按鈕...它是真的嗎?Android - editText和發送/退出按鈕

編輯:如何做到這一點,該屏幕將與主動鍵盤可見所有按鈕?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:orientation="vertical" 
android:layout_height="fill_parent" 
android:background="@drawable/poz3" 
android:padding="10dip"> 
<TextView 
    android:text="Message:" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textSize="25dip" 
    android:textColor="@color/black" 
/> 
<EditText 
    android:id="@+id/message" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:hint="Write message here" 
    android:gravity="top" 
    android:lines="7" 
    android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine" 
    android:imeOptions="actionSend|flagNoEnterAction" 
/> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:orientation="horizontal" 
    android:layout_height="fill_parent" 
> 
<Button 
    android:id="@+id/enquirySendButton" 
    android:layout_width="fill_parent" 
    android:layout_height="60dip" 
    android:text="Send" 
    android:layout_weight="1.0" 
    android:background="@drawable/custom_button" 
/> 
<Button 
    android:id="@+id/enquiryExitButton" 
    android:layout_width="fill_parent" 
    android:layout_height="60dip" 
    android:text="Cancel" 
    android:layout_weight="1.0" 
    android:background="@drawable/custom_button" 

    /> 
    </LinearLayout> 
</LinearLayout> 
+0

好友,請解釋您查詢正確。 – Mudassir

+0

或這個鏈接可以幫助你http://developer.android.com/resources/articles/on-screen-inputs.html –

+0

你可以請你發佈的XML? – ingsaurabh

回答

1

已完成了工作。 在你的XML佈局中,在主佈局(RelativeLayout)中有一個帶按鈕和android:layout_alignParentBottom =「true」的LinearLayout。下面添加其他的佈局,Android的條款:layout_above =「@ ID/yourButtonLayout」 我的現實生活中的代碼是這樣的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"  
android:textSize="14dip" 
> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/taskEditFormBottomButtons" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:baselineAligned="true" 
    android:orientation="horizontal"   
    android:layout_alignParentBottom="true" 
>   

    <Button 
     android:id="@+id/taskEditFormBTSave"   
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textStyle="bold" 
     android:text="@string/save" 
     android:layout_weight="0.5"     
    /> 

    <Button 
     android:id="@+id/taskEditFormBTCancel"   
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textStyle="bold" 
     android:text="@string/cancel" 
     android:layout_weight="0.5"     
    /> 
</LinearLayout> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_above="@id/taskEditFormBottomButtons" 
> 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     .... 
    > 
     .... 
    </RelativeLayout> 
</ScrollView> 
</RelativeLayout> 
+0

感謝您的回答,我現在要嘗試 – Waypoint

+0

偉大的,謝謝,我很驚訝它是如何工作的! – Waypoint