简体   繁体   English

Android软键盘覆盖EditText吗?

[英]Android Soft Keyboard overlay EditText?

If remove the ListView, the EditText will be auto adjust screen. 如果删除ListView,则EditText将自动调整屏幕。

If ListView exist this layout, the adjust screen will be not work and the soft keyboard overlay the EditText box. 如果ListView存在此布局,则调整屏幕将不起作用,并且软键盘将覆盖EditText框。

why ? 为什么呢? How to fix ? 怎么修 ?

And try to put this line to manifest, but also not work. 并尝试将此行显示出来,但也行不通。

android:windowSoftInputMode="stateVisible|adjustResize|adjustPan" 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>

Dont use all the three values of android:windowSoftInputMode at one time, all the values have their own significance. 不要一次使用android:windowSoftInputMode的所有三个值,所有值都有其各自的意义。

If u want that when u open the keyboard then your editBox should move up and list view should be re-sized,then u try using the following line in you manifest. 如果您希望在打开键盘时这样做,那么您的editBox应该向上移动,并且列表视图应该重新调整大小,然后尝试在清单中使用以下行。

android:windowSoftInputMode="adjustResize"

use <activity android:windowSoftInputMode="adjustResize"> in your menifest. <activity android:windowSoftInputMode="adjustResize">使用<activity android:windowSoftInputMode="adjustResize"> second add android:transcriptMode="alwaysScroll" property in your <ListView /> 第二个在<ListView />添加android:transcriptMode="alwaysScroll"属性

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

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