我有一个编辑文本:
<LinearLayout android:id="@+id/linearLayout7" android:layout_width="match_parent" android:layout_height="wrap_content">
<EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:id="@+id/editText1" android:text="3">
<requestFocus></requestFocus>
</EditText>
<Button android:text="Button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/button2"></Button>
</LinearLayout>
然后是下面的一些其他东西
我遇到的问题是,当应用程序启动时,焦点在输入上,我不希望在应用程序启动时焦点在输入上。
我尝试删除
<requestFocus></requestFocus>
事情,它什么也没做。
最佳答案
添加 android:focusable="true"
和 android:focusableInTouchMode="true"
EditText 的父布局中的元素如下;
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout7" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true" android:focusableInTouchMode="true">
我想,它应该对你有帮助。
另见;
Android Developers official guide on handling touch and input
关于android - 禁用对编辑文本的自动对焦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7593887/