开发者

Android: When the keyboard pops up, the layout is invisible. How do I solve this?

In my layout, there is a TextView at the bottom of the screen. The problem is that when I click inside the text box to type something, the keyboard covers the text box as a result of which I am not able to see what's happening... Is there any solution for this? Here's my layout...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/layout_bg">

    <ImageView
        android:id="@+id/headerimg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:paddingLeft="5dp"
        android:src="@drawable/header_image" />

    <LinearLayout 
        android:id="@+id/secondaryLayout"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="320dip"
        android:layout_marginTop = "5dip"
        android:layout_marginLeft="8dip"
        android:layout_marginRight="8dip"
        android:cacheColorHint="#00000000">

        <!-- A ListView appears here -->

    </LinearLayout>

    <RelativeLayout 
        android:id="@+id/message"
        android:orientation="horizontal"
        android:layout_width="300dip"
        android:layout_height="80dip"
        android:layout_gravity="center">

        <EditText
            android:id="@+id/MessageText"
            android:layout_height="wrap_content"
            android:layout_width="230dip"
            android:layout_marginLeft="8dip"
            android:layout_marginTop = "8dip"
            android:paddingBottom = "8dip"
            android:paddingLeft="15px"
            android:hint="Type something here...">
        </EditText>
        <Button
            android:id="@+id/MsgButton"
            android:layout_margin="0dip"
            android:layout_width="48dip"
            android:layout_toRightOf="@id/MessageText"
            android:layout_height="48dip">
        </Button>

    <开发者_开发百科;/RelativeLayout>       
</LinearLayout>


You should be able to control that in the manifest file, by adding android:windowSoftInputMode="adjustPan" attribute to the activity element. See windowSoftInputMode documentation and a blog post explaining this in more detail.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜