0

重複の可能性:
ソフトキーボードが表示されると背景レイアウトが移動する - Android

複数のビューと EditText を含むレイアウト ファイルがあります。

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
    <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/connect"
            android:id="@+id/btnConnect" android:layout_alignParentRight="true" android:layout_alignParentTop="true"/>
    <Spinner
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/spServers"
            android:layout_toLeftOf="@+id/btnConnect" android:layout_alignTop="@+id/btnConnect"
            android:layout_alignBottom="@+id/btnConnect" android:layout_alignParentLeft="true"/>
    <ToggleButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/btnType" android:layout_alignLeft="@+id/btnConnect"
            android:layout_below="@+id/btnConnect" android:layout_alignRight="@+id/btnConnect" android:textOff="@string/text"
            android:textOn="@string/grid" />
    <Spinner
            android:layout_width="98dp"
            android:layout_height="22dp"
            android:id="@+id/spDataBases" android:layout_toLeftOf="@+id/btnConnect"
            android:layout_below="@+id/btnConnect"
            android:layout_alignBottom="@+id/btnType" android:layout_alignLeft="@+id/spServers"/>
    <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/check"
            android:id="@+id/btnCheck" android:layout_alignLeft="@+id/spServers" android:layout_alignParentBottom="true"/>
    <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/run"
            android:id="@+id/btnRun" android:layout_toRightOf="@+id/btnCheck" android:layout_alignTop="@+id/btnCheck"
            android:layout_toLeftOf="@+id/btnLoad"/>
    <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/load"
            android:id="@+id/btnLoad" android:layout_alignRight="@+id/btnConnect"
            android:layout_alignTop="@+id/btnCheck"/>
    <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/txtSQL" android:layout_alignLeft="@+id/spServers" android:layout_below="@+id/btnType"
            android:layout_alignRight="@+id/btnConnect" android:layout_above="@+id/btnCheck"
            android:gravity="left|top" android:singleLine="false" android:textAlignment="gravity"/>
</RelativeLayout>

次のようになります。

ここに画像の説明を入力

しかし、何かを入力しようとすると、次の問題が発生します。

何かを入力しようとしています

これを修正してください。テキストを入力しているときに、レイアウト上の画面の位置を変更したくありません。ユーザーが何かを入力しようとすると、上に移動します。

4

1 に答える 1

0

キーボードが表示されたときにレイアウトのサイズを変更しないように Android に指示して、入力している内容が表示されるようにすることができます。(ドキュメント: http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft )

アプリのマニフェストに次を追加します: (以下のダミーのアクティビティではなく、関連するアクティビティで)

<activity android:name="Activity"
  ..
  android:windowSoftInputMode="adjustPan"
  ..
</activity>

EditTextをクリックしてキーボードが表示されたときに問題が発生しているのか、それとも入力を開始したときにのみ発生しているのかは不明です。後者の場合、私の答えはおそらく役に立たないでしょう。また、「adjustPan」が望ましい動作であるかどうかもわかりませんが、試してみる価値はあります! RelativeLayout 全体を ScrollView に配置することもお勧めします。

于 2013-01-18T23:25:01.250 に答える