android - WebView 太长。安卓

标签 android html css webview scrollview

我有WebView,把它放到scrollview。我需要那样做因为在底部 我有 ImageView 和下按钮。

问题出现在Android 4.03。 webview 比它应该的长得多。

    WebView mWebView = null;
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.clearCache(true);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.setBackgroundColor(0x00000000);
    mWebView.loadUrl("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    mWebView.setVerticalScrollBarEnabled(true);
    mWebView.setHorizontalScrollBarEnabled(true);    
    mWebView.setWebViewClient(new WebViewClient() 
    {
        @Override
        public void onPageFinished(WebView view, String url)  
        {
            super.onPageFinished(view, url);
            acceptBtn.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageStarted (WebView view, String url, Bitmap favicon)
        {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) 
        {
            return super.shouldOverrideUrlLoading(view, url);
        }

    });

和 xml:

<ScrollView 
android:layout_below="@+id/top"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/helpText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/topTerms1"
        android:layout_alignParentTop="true"
        android:layout_alignRight="@+id/topTerms1"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:gravity="center"
        android:text="@string/termsText"
        android:textColor="#777777"
        android:textSize="12dp" />

    <ImageView
        android:id="@+id/topTerms1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/helpText"
        android:layout_marginTop="5dp"
        android:src="@drawable/box_top" />      

    <WebView
        android:id="@+id/webview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/topTerms1"
        android:layout_alignRight="@+id/topTerms1"
        android:layout_below="@+id/topTerms1"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"/>



    </RelativeLayout>
</ScrollView>

最佳答案

我找到了解决方案。 webview 后面的 ImageView 太长,因为它还没有准备好显示 webview。

现在我设置主视图,加载页面,然后将 web View 添加到主视图。 问题不仅出现在尖叫冰三明治上,而且出现在所有平台上。

关于android - WebView 太长。安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9505314/

相关文章:

android - 如何在没有互联网可用时从android向服务器发送数据

Android构建不正确的gradle版本

javascript - 如何在一个事件中使用多个函数?

javascript - 单击项目时如何自动关闭移动菜单?

android - 华为 map 没有响应 Offstage Flutter

android - 在 Gplay 上发布了一个应用程序。安装后,我永远无法打开应用程序

Python字符串范围(解析html)

html - 边框长度小于 div 宽度?

css - 响应列没有加起来..?

css - 在哪里可以找到 Bootstrap 2.3 CDN?