Android键盘在Web视图中隐藏输入 [英] Android keyboard hides input in web view
本文介绍了Android键盘在Web视图中隐藏输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Android网络视图中,当触摸文本/密码字段时,键盘会出现,但会覆盖该字段,从而迫使用户滚动查看其输入内容.
In an Android webview, when a text/password field is touched, the keyboard appears but covers the field, forcing the user to scroll to see what they are typing.
是否有解决此问题的方法或在Web视图中具有自动聚焦的方法?(如iOS中所示).
Is there a way to solve this issue or a way to have an auto-focus in web view ? (as seen in 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>
我也在这里粘贴样式和颜色:
I also paste styles and colors here:
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="splash_background">#e11020</color>
</resources>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#e11020</item>
<item name="colorPrimaryDark">#e11020</item>
<item name="colorAccent">#e11020</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<!-- SplashTheme -->
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash_theme</item>
</style>
</resources>
推荐答案
尝试添加以下属性:
android:fitsSystemWindows="true"
.xml布局的根LinearLayout中.
in the root LinearLayout of the .xml layout.
这篇关于Android键盘在Web视图中隐藏输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文