键入时无法查看滚动视图中的编辑文本

Mic*_*ner 1 android scrollview android-softkeyboard android-edittext

EditText尝试输入时,软键盘掩盖了我的字段EditText

如何防止软键盘遮盖我的EditText领域?

按下返回按钮后,我可以看到我输入的内容,因为软键盘不再覆盖了EditText

我正在使用银河10.1英寸平板电脑。

XML格式

<ScrollView
            android:layout_width="wrap_content"
            android:layout_height="400dp" >

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

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="1) Project"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/projectET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:textSize="25sp"
                        android:ems="10"
                        android:hint="Project" 
                        android:inputType="textCapWords"
                        android:layout_gravity="bottom"/>

                    <CheckBox
                        android:id="@+id/projectCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp" />

                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="2) Customer"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/customerET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:inputType="textCapWords"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:hint="Customer" />

                    <CheckBox
                        android:id="@+id/customerCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/material1"
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="3) Material"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/materialET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:textSize="25sp"
                        android:layout_gravity="bottom"
                        android:inputType="textCapWords"
                        android:ems="10"
                        android:hint="Material" />

                    <CheckBox
                        android:id="@+id/materialCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="4) Phase"
                        android:layout_gravity="bottom"
                        android:textColor="#000000"
                        android:textSize="25sp" />

                    <EditText
                        android:id="@+id/fazeET"
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="Phase" />

                    <CheckBox
                        android:id="@+id/fazeCBM"
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="5)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="6)"
                        android:layout_gravity="bottom"
                        android:textColor="#000000"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="7)"
                        android:layout_gravity="bottom"
                        android:textColor="#000000"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="55dp"
                        android:enabled="false" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="8)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="55dp"
                        android:layout_height="wrap_content"
                        android:enabled="false" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="9)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="55dp"
                        android:layout_height="wrap_content"
                        android:enabled="false" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="wrap_content"
                        android:text="10)"
                        android:textColor="#000000"
                        android:layout_gravity="bottom"
                        android:textSize="25sp" />

                    <EditText
                        android:layout_width="500dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:layout_gravity="bottom"
                        android:textSize="25sp"
                        android:enabled="false"
                        android:hint="" />

                    <CheckBox
                        android:layout_width="55dp"
                        android:layout_height="wrap_content"
                        android:enabled="false" />
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
Run Code Online (Sandbox Code Playgroud)

pro*_*007 5

您需要使用windowSoftInputMode。键盘抬起时,这将允许您调整UI的大小。允许用户EditText在键入键盘时看到。

将此属性添加到您的AndroidManifest.xml中Activity

android:windowSoftInputMode="adjustPan"
Run Code Online (Sandbox Code Playgroud)

参考