android - Android 上的软键盘会遮盖文本框,因此用户看不到正在输入的内容

标签 android webview

我做不到,它不关注 webview 的输入或文本区域

我点击了最后一次输入。;

http://i.stack.imgur.com/MGG3L.png

应该和这个一样(安卓浏览器)

http://i.stack.imgur.com/WFRta.png

我该怎么办?

主要 Activity .js;

webview = (WebView) findViewById(R.id.webView1);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl("http://mutlugunluk.com");


        webview.requestFocus(View.FOCUS_DOWN);
        webview.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                    case MotionEvent.ACTION_UP:
                        if (!v.hasFocus()) {
                            v.requestFocus();
                        }
                        break;
                }
                return false;
            }
        });

Activity 主体

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <WebView
            android:id="@+id/webView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
</RelativeLayout>

list

<activity
        android:windowSoftInputMode="adjustPan|adjustResize"
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

最佳答案

您是否尝试将 Window SoftInput Mode 属性设置为 Activity 的 adjustPan 和 adjustResize?

在为该 Activity 设置的 Manifest.xml 中:

<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>

当键盘弹出时,这应该可以实现将所有内容向上移动的“技巧”。

注意:如果顶部元素是 RelativeLayout,这应该有效,所以尝试将 LinearLayout 更改为 RelativeLayout

关于android - Android 上的软键盘会遮盖文本框,因此用户看不到正在输入的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32171294/

相关文章:

android - BLE gatt.discoverServices() 返回 true 但回调永远不会触发

javascript - react-native `keyboardShouldPersistPanGesture` 事件,防止键盘在快速滑动事件中消失

webview - 如何在屏幕更改时处理 Flutter WebviewScaffold?

Eclipse 无法识别我的 Android 设备

android - 通知背景图片从未在时钟上显示

wpf - UWP Webview 导航到 Localhost 页面(未找到 404)

objective-c - WebView 动态加载 css

android - 在 WebView 中加载图像

java - 如何在android webview中阻止google adsense广告?

数组列表中的 java.util.ConcurrentModificationException