Android键盘在Web视图中隐藏输入

在Android网络视图中,当触摸文本/密码字段时,键盘会出现,但会覆盖该字段,从而迫使用户滚动查看他们正在输入的内容。

是否有解决此问题的方法或在Web视图中具有自动聚焦的方法? (如iOS中所示)。

清单

react-native run-android

布局

<?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>

我也在这里粘贴样式和颜色:

colors.xml

<?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>

styles.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>
pk110987 回答:Android键盘在Web视图中隐藏输入

尝试添加以下属性:

android:fitsSystemWindows="true"

.xml布局的根LinearLayout中。

,

您可能想查看这篇文章: https://developer.android.com/training/keyboard-input/visibility

也许这会对您有所帮助。

android:windowSoftInputMode="adjustResize"
,

您可以尝试以下属性:

  • 在清单文件中,您在其中注册活动:

    <activity android:name="yourActivity"
       android:windowSoftInputMode="stateHidden"/>
    
,

有两种选择:

替代1:

要使单行聚焦,请使用以下命令:

webView.requestFocus(View.FOCUS_DOWN);

替代2:

webView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view,MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_UP:
                view.requestFocusFromTouch();  
                break;
        }               
        return false;
    }

});

我希望它能帮助您...!

,

您好,请检查以下问题,您可以得到答案。

  

Input Text Field hidden below keyboard in Android webview

,

尝试这个。

webView.getSettings().setJavaScriptEnabled(true);

webView.setWebViewClient(new WebViewClient() {
    @Override
    public void onPageFinished(WebView view,String url) {
        view.loadUrl("javascript:document.getElementsByName('[your view name without square brackets]')[0].focus();");
        super.onPageFinished(view,url);
    }
});

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,0);
,

当应用使用全屏模式时,Android键盘会隐藏。

如果您使用此问题可以解决

<item name="android:windowFullscreen">false</item>以您的样式。

然后使用<activity android:name=".MainActivity" android:windowSoftInputMode="adjustResize">

在您的清单中。

,

我通过以下答案解决了这个问题

android:fitsSystemWindows="true" 在根 LinearLayout @animeshk 中

<item name="android:windowFullscreen">false</item> 主题风格@Nawin

就我而言,它在不添加 android:windowSoftInputMode="adjustResize"

的情况下运行良好
本文链接:https://www.f2er.com/2913376.html

大家都在问