在Android Web视图中,当触摸文本/密码字段时,出现键盘,但键盘覆盖了该字段,迫使用户滚动查看其输入内容。
是否有解决此问题的方法或在Web视图中具有自动聚焦的方法? (如iOS中所示)。
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dedalos.amb">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme">
<activity android:name=".SplashScreen" android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
</activity>
</application>
</manifest>
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/splash_background"
tools:context=".MainActivity">
<WebView
android:id="@+id/ambWebViewLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/splash_background" />
</LinearLayout>
您可能要查看这篇文章:https://developer.android.com/training/keyboard-input/visibility
也许这会帮助您。
android:windowSoftInputMode="adjustResize"