【问题标题】:''Done" button not visible anymore when typing in EditText field在 EditText 字段中键入时,“完成”按钮不再可见
【发布时间】:2019-02-12 09:30:25
【问题描述】:

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

此问题仅在一周前出现,在手机(荣耀 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
}

任何帮助将不胜感激!

【问题讨论】:

  • 看看this
  • 向我们展示更多细节,例如您的整个布局代码。
  • @HemantParmar 我就是这样用的
  • 您是否尝试禁用自动完成功能?
  • @KaranMer 是的,不幸的是它没有帮助。

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


【解决方案1】:

试试这个:

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);

我已经为我检查了多个设备的工作情况

希望对你有帮助

【讨论】:

  • 如果你检查我的问题,你可以看到 android:imeOptions="actionDone" 已经在我的代码中
【解决方案2】:

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

android:singleLine="true"

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    • 2016-11-25
    • 1970-01-01
    相关资源
    最近更新 更多