0

I am developing an application for Android.

I have a simple layout. A CheckBox, a Spinner and a Button at the top, a two line EditText at the Bottom which is displayed when the CheckBox is checked and another EditText which covers the rest of the space in the middle.

The problem is that when I am writing on the big EditText, sometimes the layout goes out of the screen on top and as a result I can't see what I am writing.

As a solution, I can set my layout to resize when the keyboard shows (using android:windowSoftInputMode="adjustResize" on the manifest.xml) but that won't be good since I do not want the 2 EditTexts to share the space left on the screen.

My layout code follows:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button android:id="@+id/button"
        android:text="Push"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content" 
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"/>
    <CheckBox android:id="@+id/check_box"
        android:text="Check"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true" />
    <Spinner android:id="@+id/spinner"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />   
    <EditText android:id="@+id/text_2"
        android:hint="@string/hint_2"
        android:inputType="textMultiLine"
        android:maxLines="2"
        android:gravity="top"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_alignParentBottom="true"
        android:visibility="gone" />    
    <EditText android:id="@+id/text_1"
        android:hint="@string/hint_1"
        android:inputType="textMultiLine"
        android:gravity="top"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/spinner"
        android:layout_above="@id/text_2"
        android:layout_alignWithParentIfMissing="true" />
</RelativeLayout>

P.S. This thing happens only on my Wildfire and very rare on the Emulator. A friend's Desire HD didn't have any problem at all. I don;t know if this makes any difference...

Thanks in advance for your help.

Antonis

4

1 に答える 1

0

私はまったく同じ問題を抱えています。私がテストしたところ、これは複数行モードの EditText でのみ発生し、SoftInputMode がadjustPan に設定されている場合にのみ発生します。これはおそらく Android のバグです。

私が見つけた唯一の解決策は、adjustPan を削除することです。

于 2012-01-06T19:12:55.610 に答える