2011-03-10 56 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