2017-09-01 107 views
1

我希望EditText不会在专注于Android Wear时扩展IME。 我的阅读和实施方法与以下主题相同: Prevent EditText from automatically focusing如何在EditText专注时隐藏IME

但是,IME出现。 Android Wear上的EditText无法隐藏IME吗?

我试图3种方法:

  1. 添加在OnCreate以下代码()方法:

    {getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);} 
    
  2. 添加了在活动标签下面的代码在AndroidManifest.xml

    android:windowSoftInputMode="stateAlwaysHidden" 
    
  3. 在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

+0

检查这一个.. https://stackoverflow.com/questions/2429595/how-to-stop-the-android-soft-keyboard-from-ever-coming-up-in-my-entire-applicati –

回答

0

检查Show the Input Method On Demand。值得注意的是,当用户在测试字段中完成任务时,系统会隐藏输入法,或者用户可以使用系统控制来隐藏输入法。有了这个,请尝试specify how your UI should respond。提到的是,

要声明您在某项活动中的首选待遇,请在清单元素中使用android:windowSoftInputMode属性并使用其中一个“调整”值。

然后,要实现隐藏IME,请尝试使用InputMethodManager,常数设置为RESULT_UNCHANGED_HIDDEN。这将标记来自showSoftInput(View, int, ResultReceiver)hideSoftInputFromWindow(IBinder, int, ResultReceiver)ResultReceiver结果代码:软输入窗口的状态保持不变并保持隐藏状态。

希望有所帮助。