Android: когда клавиатура выскакивает, раскладка невидима. Как мне это решить? - PullRequest
3 голосов
/ 18 декабря 2009

В моем макете есть TextView внизу экрана. Проблема в том, что когда я щелкаю внутри текстового поля, чтобы напечатать что-то, клавиатура закрывает текстовое поле, в результате чего я не могу видеть, что происходит ... Есть ли какое-то решение для этого? Вот мой макет ...

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

1 Ответ

14 голосов
/ 18 декабря 2009

Вы должны иметь возможность контролировать это в файле манифеста, добавив атрибут android: windowSoftInputMode = "AdjustPan" к элементу действия. См. документацию windowSoftInputMode и сообщение в блоге , объясняющее это более подробно.

...