开发者

Layout scrolls up when keyboard appears

I've got some trouble developing an Android application: I've created a TabActivity and put a layout in it, which will be used for instant messaging. When I try to put some text in the im_messageText field, whole layout moves up so that the keyboard can fit in, which is quite inconvinient. What should I do to make im_historyHolder resize instead of scolling?

Here's the code:

Instant messenger layout:

<LinearLayout
    android:id="@+id/im_mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout 
        android:id="@+id/im_captionLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <Button 
            android:id="@+id/im_backButton"
            android:layout_width="wrap_content"
            android:开发者_JAVA百科layout_height="wrap_content"
            android:text="Back"/>
        <TextView 
            android:id="@+id/im_buddyName"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="%USERNAME%"
            android:layout_weight="1"
            android:gravity="center_horizontal|center_vertical"
            android:textAppearance="?android:attr/textAppearanceLarge"/>
    </LinearLayout>
    <ScrollView 
        android:id="@+id/im_scroll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">
        <RelativeLayout 
            android:id="@+id/im_historyHolder"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        </RelativeLayout>
    </ScrollView>
    <LinearLayout 
        android:id="@+id/im_sendLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <EditText 
            android:id="@+id/im_messageText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"/>
        <Button 
            android:id="@+id/im_sendButton"
            android:text="Send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</LinearLayout>

TabActivity layout:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>

Screenshots:

Layout scrolls up when keyboard appears

Layout scrolls up when keyboard appears


It is handled by device and you can't handle it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜