相关疑难解决方法(0)

Android:键盘打开时Webview滚动不足

在我的应用程序中,我有一个Web视图,该视图加载了用户应在其中执行身份验证的网页。当用户在网页中选择某个输入字段时,Webview应:

  1. 专注于领域
  2. 打开键盘
  3. 执行向上滚动以便用户继续查看该字段

但是,Web视图不会自动向上滚动,因此用户不再看到该字段。如果用户尝试手动滚动,则Webview只会进行少量滚动-不足以使用户看到他需要的所有内容。问题不在于网页本身,因为当我使用android chrome浏览到该网页时,它确实向上滚动以保持字段可见,并允许滚动到页面底部。我已经阅读了以下问题: 键盘打开时WebView不滚动adjustPan不能阻止键盘覆盖EditText, 但是答案不能解决问题。

我当前的activity_web_viewlogin.xml:

<LinearLayout 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"
    android:id="@+id/portalWebViewWrapper"
    android:orientation="vertical"
    tools:context="com.hpe.sb.mobile.app.features.login.activities.WebViewLoginActivity">
    <include
        android:id="@+id/app_bar"
        layout="@layout/app_bar" />

   <ScrollView android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:fillViewport="true">

        <WebView
            android:id="@+id/portalWebView"
            android:layout_below="@id/app_bar"
            android:layout_width="match_parent"
            android:layout_margin="@dimen/activity_vertical_margin"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />

   </ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

还尝试了ScrollView包含LinearLayout。

在我的AndroidManifest.xml中:

        <activity
           android:name=".features.login.activities.WebViewLoginActivity"
           android:windowSoftInputMode="adjustResize"
           android:label="" />
Run Code Online (Sandbox Code Playgroud)

也尝试了AdjustPan而不是AdjustResize。

提前致谢!

android scrollview webview

6
推荐指数
1
解决办法
5051
查看次数

Android webview滚动不起作用

我正在尝试在 webview 中向下滚动到页面底部,我正在使用他们教程中提供的 webview 示例 google。我正在使用这行代码尝试滚动,但它不起作用。mWebView.pageDown(true); 关于如何以编程方式滚动的任何建议?谢谢你。

public class WebViewExample extends Activity {

private static final String LOG_TAG = "WebViewDemo";

private WebView mWebView;

private Handler mHandler = new Handler();

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    mWebView = (WebView) findViewById(R.id.webview);

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(false);

    mWebView.setWebChromeClient(new MyWebChromeClient());

    mWebView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");

    mWebView.loadUrl("http://www.google.com/search?q=android+webview+scroll+doesnt+work&hl=en&safe=off&prmd=ivns&ei=0b0cTquNNI6WsgP6l7igBQ&start=10&sa=N#sclient=psy&hl=en&safe=off&source=hp&q=android%20webview%20scrollable&pbx=1&oq=&aq=&aqi=&aql=&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=c306e119a7d85f91&biw=1280&bih=738&pf=p&pdl=300");

           //this is where I try to scroll, doesn't work
           mWebView.pageDown(true);

}

final class DemoJavaScriptInterface {

    DemoJavaScriptInterface() {
    }

    /**
     * This is not called on …
Run Code Online (Sandbox Code Playgroud)

java android

5
推荐指数
1
解决办法
3597
查看次数

标签 统计

android ×2

java ×1

scrollview ×1

webview ×1