开发者

Android - editText and send/exit buttons

I am finishing implementing an application, which has inside activity for sending a message (just editText and two buttons - send and cancel, message is then send to the fixed address). When i start this activity, on a screen I see textBox and keyboard, which is immediately shown. But disadvantage of this is that theese buttons are covered or half-covered by the keyboard and all I want is to have is similar as in the messages. When keyboard is visible, shrink the text field and show in addtion buttons above the keyboard, if I hit back arrow on under the screen, keyboard dissapears, nearly whole screen would be taken by this editText and on the bottom there will be those two buttons... can it be real?

Edit: How to make it happen, that this screen will have with active keyboard visible all buttons?

<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="6开发者_如何转开发0dip"
  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>


have got it working. In your XML layout, in the main layout (RelativeLayout) have a LinearLayout with the buttons and android:layout_alignParentBottom="true". Add your other layout below, with clause android:layout_above="@id/yourButtonLayout" My real life code goes like this:

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


This might be of some help,if not already tried..

http://developer.android.com/resources/articles/on-screen-inputs.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜