简体   繁体   English

为什么我的Android键盘会自动打开?

[英]why does my android keyboard opens automatically?

I have this Layout. 我有这个布局。
every time it's opened, the android keyboard appears 每次打开时,都会出现android键盘

why is that? 这是为什么?

how can I avoid this? 我该如何避免呢?

Add this to your manifest file, You can avoid that. 将此添加到清单文件中,可以避免这种情况。

    <activity
        android:name="Your_Activity"
        android:windowSoftInputMode="stateAlwaysHidden" >
    </activity>

If the EditText has requestFocus ,then keyboard might display automatically. 如果EditText具有requestFocus ,则键盘可能会自动显示。 It has nothing to do with your xml code. 它与您的xml代码无关。

Add the following line to your Manifest File inside each Activity tab 将以下行添加到每个“活动”选项卡中的清单文件中

android:windowSoftInputMode="stateAlwaysHidden" 

or add the following to your parent layout in that activity 或将以下内容添加到该活动的父级布局中

android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"

Strange ! 奇怪! I thought Screen which has editText only get focus. 我以为具有editText的Screen只能得到关注。

Try this => Stop EditText from gaining focus at Activity startup 试试这个=> 阻止EditText在Activity启动时获得关注

Android opens the OnScreenKeyboard automatically if you have an EditText focussed . 如果您将EditText放在焦点上,则Android将自动打开OnScreenKeyboard。

You can prevent that by adding following into your Activity's onCreate method. 您可以通过在Activity的onCreate方法中添加以下内容来避免这种情况。

getWindow().setSoftInputMode(
    WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:带EditText的AlertDialog不会自动显示键盘 - Android: AlertDialog with EditText does not automatically show the Keyboard 如何清除TextInputLayout中第一个Edittext的焦点,它会自动聚焦并在android中打开键盘? - How to clear the Focus of the First Edittext in TextInputLayout which is automatically focussed and opens keyboard in android? 为什么Tomcat为我的应用程序打开了如此多的Java进程? - Why does Tomcat opens so many Java Processes for my Application? 打开键盘时,Android TextViews是否清除? - Android TextViews clearing when keyboard opens? 为什么重新启动的Java程序会失去键盘焦点? - Why does my restarted Java program lose keyboard focus? 为什么在Android键盘上按Go键会向onEditActionListener发送两个KeyEvent - Why does pressing the Go on the android keyboard send two KeyEvents to onEditActionListener 为什么键盘向上推可能会布局并消失我的标题android? - Why keyboard is pushing up may layout and vanishing my header android? Android-键盘打开时不调整的表单内容 - Android- Content of forms not adjusting when keyboard opens 为什么我打开的 ResultSet 在更改 session 后会自动关闭 - Why does my open ResultSet automatically close after alter session 为什么JPA不会自动生成我的行的ID? - Why JPA does not generate automatically an id for my rows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM