在web视图Android的删除不需要的空白 [英] Remove unwanted White Space in WebView Android

查看:189
本文介绍了在web视图Android的删除不需要的空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid。我已经开始开发一个应用程序使用的WebView。其实我加载与web视图图像(我喜欢用类的内置变焦控制)。我可以成功加载图像,但我可以看到一些刺激性的空白。我找不到的方式将其删除。我的图片是750 * 1000的尺寸。我重视我的codeS下方,任何帮助将是很大的AP preciated!

I am new to Android. I have started developing an App using WebView. Actually I am loading an Image with Webview (I like to use the built-in zoom controls of the class). I can successfully load the Image but I can see some irritating white spaces. I can't find the way to remove it. My Images are 750 * 1000 in size. I have attached my codes below, Any help would be greatly appreciated!!!

webview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
    <WebView
        android:id="@+id/webView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

ImageViewer.java

package com.android.test;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class ImageViewer extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        String loadUrl = "file:///android_res/drawable/splash_001.jpg";

        WebView image = (WebView) findViewById(R.id.webView);
        image.clearView();
        image.clearCache(true);
        image.getSettings().setBuiltInZoomControls(true);
        image.getSettings().setSupportZoom(true);
        image.getSettings().setLoadWithOverviewMode(true);
        image.getSettings().setUseWideViewPort(true);
        image.loadUrl(loadUrl);
    }

}

请帮助我!

推荐答案

在默认情况下的的WebView 有一定的保证金/填充体。如果你想删除填充/保证金,然后覆盖身体的标签,然后像增加保证金:

By default webview has some margin/padding in body. If you want to remove that padding/margin then override body tag and add margin like:

<body style="margin: 0; padding: 0">

这篇关于在web视图Android的删除不需要的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆