繁体   English   中英

Android软键盘覆盖EditText吗?

[英]Android Soft Keyboard overlay EditText?

如果删除ListView,则EditText将自动调整屏幕。

如果ListView存在此布局,则调整屏幕将不起作用,并且软键盘将覆盖EditText框。

为什么呢? 怎么修 ?

并尝试将此行显示出来,但也行不通。

android:windowSoftInputMode =“ stateVisible | adjustResize | adjustPan”

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="TextView" />

        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="200dip" >
        </ListView>
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <Spinner
            android:id="@+id/spinner1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10" >

            <requestFocus />
        </EditText>
    </LinearLayout>

</LinearLayout>

不要一次使用android:windowSoftInputMode的所有三个值,所有值都有其各自的意义。

如果您希望在打开键盘时这样做,那么您的editBox应该向上移动,并且列表视图应该重新调整大小,然后尝试在清单中使用以下行。

android:windowSoftInputMode="adjustResize"

<activity android:windowSoftInputMode="adjustResize">使用<activity android:windowSoftInputMode="adjustResize"> 第二个在<ListView />添加android:transcriptMode="alwaysScroll"属性

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM