[英]How to hide IME when EditText is focused
I want EditText
not to extend IME when it is focused on Android Wear. 我希望
EditText
在专注于Android Wear时不扩展IME。 I read and implemented in the same way as the following thread: Prevent EditText from automatically focusing 我以与以下线程相同的方式阅读和实现: 防止EditText自动聚焦
However, IME appears. 但是,IME出现。 Is it impossible to hide IME for an
EditText
on Android Wear? 是否可以在Android Wear上为
EditText
隐藏IME?
I tried 3 methods: 我尝试了3种方法:
Added the following code in the onCreate() method: 在onCreate()方法中添加了以下代码:
{getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);}
Added the following code in the activity tag in AndroidManifest.xml 在AndroidManifest.xml的活动标记中添加了以下代码
android:windowSoftInputMode="stateAlwaysHidden"
Added the following code in rect_activity_main.xml 在rect_activity_main.xml中添加了以下代码
<LinearLayout android:layout_width="0dp" android:layout_height="0dp" android:background="@android:color/transparent" android:focusable="true" android:focusableInTouchMode="true"/>
None of them worked. 他们都没有工作。
Best regards, gellpro 最好的问候,gellpro
Check Show the Input Method On Demand . 选中显示按需输入法 。 It's noted that the system hides the input method when the user finishes the task in the test field or the user can hide it with a system control.
请注意,当用户在测试字段中完成任务时,系统将隐藏输入法,或者用户可以使用系统控件将其隐藏。 With this, try to specify how your UI should respond .
以此尝试尝试指定UI的响应方式 。 It's mentioned that,
提到了
To declare your preferred treatment in an activity, use the
android:windowSoftInputMode
attribute in your manifest's element with one of the "adjust" values.要在活动中声明您的首选处理方式,请在清单元素中使用
android:windowSoftInputMode
属性以及“ adjust”值之一。
Then, to implement hiding IME, try using InputMethodManager with constant set to RESULT_UNCHANGED_HIDDEN
. 然后,要实现隐藏的IME,请尝试使用常数设置为
RESULT_UNCHANGED_HIDDEN
InputMethodManager 。 This will flag for the ResultReceiver
result code from showSoftInput(View, int, ResultReceiver)
and hideSoftInputFromWindow(IBinder, int, ResultReceiver)
: the state of the soft input window was unchanged and remains hidden. 这将标记来自
showSoftInput(View, int, ResultReceiver)
和hideSoftInputFromWindow(IBinder, int, ResultReceiver)
的ResultReceiver
结果代码:软输入窗口的状态未更改,并保持隐藏状态。
Hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.