在Android Pie(API-28)中进入活动状态时,键盘不显示 [英] Keyboard doesn't show up when enter to activity in Android Pie (API-28)

查看:69
本文介绍了在Android Pie(API-28)中进入活动状态时,键盘不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在进入电子邮件登录"屏幕时弹出设备键盘.

I want to pop up the device keyboard when I enter to Email Login screen.

我在 AndroidManifest.xml 文件中将windowSoftInputMode声明为"stateVisible":

<activity
        android:name=".activities.EmailLoginActivity"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"   
        android:windowSoftInputMode="stateVisible" />

我已遵循此文档.

结果:

在运行Android API最高为27的设备上,将显示键盘.

On devices that run Android API up to 27, the keyboard is shown.

在运行Android API 28的设备上,未显示键盘.

On devices that run the Android API 28, the keyboard is not shown.

这是Android Pie中的错误吗?

Is it a bug in Android Pie?

有什么建议吗?

推荐答案

似乎在Android Pie(API 28)中,它不会自动在EditText中设置请求焦点.

Seems in Android Pie (API 28), it is not setting request focus in EditText automatically.

因此,您必须以编程方式或在XML文件中设置EditTextrequestFocus.

So you have to set the requestFocus of your EditText either programmatically or in the XML file.

your_layout.xml

<EditText
        android:id="@+id/et_email"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/_20sdp"
        android:inputType="textEmailAddress"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <requestFocus />
    </EditText>

OR

your_activity.java

findViewById(R.id.et_email).requestFocus();

这篇关于在Android Pie(API-28)中进入活动状态时,键盘不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆