![](/img/trans.png)
[英]Stop EditText from gainning focus when another EditText clear focus
[英]Focus on EditText is clear when click on it
我的问题是当我点击EditText输入东西时,键盘出现了,EditText上的焦点消失了,所以我需要再次点击,然后才能打字。 有什么问题? XML 中的代码很简单
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg">
<EditText
android:id="@+id/et_phone"
android:layout_width="0dp"
android:layout_height="40dp"
android:background="@drawable/bg_et"
android:paddingVertical="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:hint="@string/enter_phone_hint"
android:paddingHorizontal="16dp"/>
尝试将windowSoftInputMode
添加到您的清单文件中的Activity
。 将其设置为adjustPan
。
AndroidManifest.xml
<activity
android:name=".MainActivity"
android:exported="true"
android:windowSoftInputMode="adjustPan">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.