在EditText字段中键入时,“完成”按钮不再可见

时间:2019-02-12 09:30:26

标签: android android-layout android-edittext swift-keyboard

我的应用程序中有一个EditText字段,用户可以在其中输入数据。 该应用程序以编程方式处于全屏模式。问题是,在某些手机(Honor P Smart)上,如您在图片上所见,“完成”按钮不再可见。

仅在一周前,手机(Honor P Smart)收到更新(固件Fig-lx1 8.0.0.140(c02))后出现了此问题。在更新之前,“完成”按钮可见。我应该提到,SwiftKey不是问题的根源,因为我在其他使用SwiftKey的手机上进行了尝试,并且效果很好。

也:为什么第二个全屏显示而第一个不显示?如何强制全屏显示?

这是EditText字段的xml代码:

<EditText 
    android:id="@+id/label" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginEnd="@dimen/margin_left" 
    android:layout_marginStart="@dimen/margin_left" 
    android:cursorVisible="false" 
    android:imeActionLabel="@string/done" 
    android:hint="@string/something" 
    android:imeOptions="actionDone" 
    android:inputType="textVisiblePassword" 
    android:lineSpacingExtra="6sp" 
    android:textColor="@color/color_x" 
    android:textSize="32sp" />

我通过以下方式设置侦听器:

view.enar_button_label.setOnEditorActionListener { textView, actionID, keyEvent ->
    if (actionID == EditorInfo.IME_ACTION_DONE) {
        // hiding keyboard, because for some reason, it does not hide automatically
        (activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).hideSoftInputFromWindow(view.enar_button_label.windowToken, 0)
        // soome stuff...
        (activity as MainActivity).setImmersiveMode()
        return@setOnEditorActionListener true
    }
    return@setOnEditorActionListener false
}

Honor P smart

Other phones

任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:0)

尝试一下:

xml代码:


           <EditText
            android:id="@+id/login_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/margin_30"
            android:layout_marginRight="@dimen/margin_30"
            android:layout_marginBottom="@dimen/margin_20"
            android:gravity="center"
            android:hint="@string/username"
            android:maxLength="40"
            android:padding="@dimen/padding_10"
            android:imeOptions="actionDone"
            android:singleLine="true" />

将此内容添加到EditText

  

android:imeOptions =“ actionDone”

java代码:


     emailedit = (EditText) findViewById(R.id.login_email);

     emailedit.setImeOptions(EditorInfo.IME_ACTION_DONE);

设置代码行

  

emailedit.setImeOptions(EditorInfo.IME_ACTION_DONE);

我已经为我检查了多个设备,

我希望它能对您有所帮助

答案 1 :(得分:0)

@blade 只需在您的编辑文本标签中添加以下行。 那么问题就迎刃而解了。

android:singleLine="true"

如果您遇到任何问题,请告诉我。

相关问题