Android:键盘并不总是显示在编辑文本焦点上
我有一个登录视图。当用户启动应用程序时,如果之前已与服务器同步,则应用程序将在登录视图中打开,并提示用户输入其登录名。在这种情况下,当应用程序启动时,键盘会自动打开。但是,如果用户以前从未同步过,则该用户将重定向到配置视图,并将从那里同步。同步结束后,配置活动完成,用户将第一次看到登录视图。此时,焦点应该放在PIN编辑文本上,但键盘没有打开 我尝试了网上找到的几种解决方案,但都不奏效。这是我当前状态下的代码: 视图: 布局:Android:键盘并不总是显示在编辑文本焦点上,android,ios,Android,Ios,我有一个登录视图。当用户启动应用程序时,如果之前已与服务器同步,则应用程序将在登录视图中打开,并提示用户输入其登录名。在这种情况下,当应用程序启动时,键盘会自动打开。但是,如果用户以前从未同步过,则该用户将重定向到配置视图,并将从那里同步。同步结束后,配置活动完成,用户将第一次看到登录视图。此时,焦点应该放在PIN编辑文本上,但键盘没有打开 我尝试了网上找到的几种解决方案,但都不奏效。这是我当前状态下的代码: 视图: 布局: <?xml version="1.0" encoding="ut
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="view.Login">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<include layout="@layout/app_bar" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<EditText
android:id="@+id/passwordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/lgnEditTextMarginLeft"
android:textSize="@dimen/textSizeL"
android:ems="8"
android:inputType="numberPassword"
android:selectAllOnFocus="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="horizontal">
<Button
android:id="@+id/btnSynchroniser"
style="@style/RexforetTheme.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/btn_marge_top"
android:drawableLeft="@drawable/icon_sync"
android:textSize="@dimen/textSizeM"
android:text="@string/btn_synchroniser" />
<Button
android:id="@+id/btnConfiguration"
style="@style/RexforetTheme.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/btn_marge_top"
android:drawableLeft="@drawable/icon_configuration"
android:textSize="@dimen/textSizeM"
android:text="@string/btn_configuration" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
舱单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ca.aaa.bbb">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/RexforetTheme">
<activity android:name="view.Login">
<intent-filter>
<action android:name="android.intent.action.MAIN"
android:windowSoftInputMode="stateVisible"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="view.MenuPrincipal" />
<activity android:name="view.Configuration" />
<service
android:name="service.WebDBService"
android:exported="false"/>
</application>
</manifest>
这里有android:WindowsOfInputMode=“stateVisible”替换
android:windowSoftInputMode="stateHidden|adjustPan"
在您的menifest文件中此处有android:WindowsOfInputMode=“stateVisible”
android:windowSoftInputMode="stateHidden|adjustPan"
在您的menifest文件中此处有android:WindowsOfInputMode=“stateVisible”
android:windowSoftInputMode="adjustResize"
在您的清单文件中。此处有android:WindowsOfInputMode=“stateVisible”
android:windowSoftInputMode="adjustResize"
在您的清单文件中。这不起作用,但我想问:尝试此操作的原因是什么?活动的主窗口总是调整大小,以便为屏幕上的软键盘腾出空间。感谢您的澄清。这不起作用,但我想问:为什么要这样做?活动的主窗口总是调整大小,以便为屏幕上的软键盘腾出空间。感谢您的澄清。