gpt4 book ai didi

android - 打字时看不到 ScrollView 中的编辑文本

转载 作者:行者123 更新时间:2023-11-29 15:26:39 25 4
gpt4 key购买 nike

尝试输入 EditText 时,软键盘遮住了我的 EditText 字段。

如何防止软键盘覆盖我的 EditText 字段?

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

我使用的是 galaxy 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>

最佳答案

您需要使用 windowSoftInputMode .这将允许您的 UI 在键盘出现时调整大小。允许用户在键盘输入时看到 EditText

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

android:windowSoftInputMode="adjustPan"

Reference

关于android - 打字时看不到 ScrollView 中的编辑文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11885289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com