我希望EditText
在专注于Android Wear时不扩展IME。
我以与以下线程相同的方式阅读和实现:
Prevent EditText from automatically focusing
但是,IME出现。
是否可以在Android Wear上为EditText
隐藏IME?
我尝试了3种方法:
在onCreate()方法中添加了以下代码:
{getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);}
在AndroidManifest.xml的活动标记中添加了以下代码
android:windowSoftInputMode="stateAlwaysHidden"
在rect_activity_main.xml中添加了以下代码
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:focusable="true" android:focusableInTouchMode="true"/>
他们都没有工作。
最好的问候,gellpro
最佳答案
检查Show the Input Method On Demand。注意,当用户在测试字段中完成任务时,系统将隐藏输入法,或者用户可以使用系统控件将其隐藏。这样,尝试specify how your UI should respond。提到了
要在活动中声明首选治疗,请在清单元素中将android:windowSoftInputMode
属性与“ adjust”值之一一起使用。
然后,要实现隐藏的IME,请尝试使用常量设置为RESULT_UNCHANGED_HIDDEN
的InputMethodManager。这将标记来自ResultReceiver
和showSoftInput(View, int, ResultReceiver)
的hideSoftInputFromWindow(IBinder, int, ResultReceiver)
结果代码:软输入窗口的状态未更改,并保持隐藏状态。
希望能有所帮助。