Android的web视图内容重叠,而使用透明背景 [英] Android Webview Content Overlapping While Using Transparent Background

查看:285
本文介绍了Android的web视图内容重叠,而使用透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个问题已经被问过<一个href="http://stackoverflow.com/questions/5898196/how-to-resolve-overlapping-the-content-of-the-webview-closed">How解决重叠的WebView的内容这里,但它被关闭的某些原因。但这里是发生了什么。我创建了一个web视图,应用透明的背景,但是当我尝试再次加载的东西,并重新加载的东西,旧的内容将仍然留在web视图和新的人会重复它。下面是解释它的图片。

I found that this question has been asked before How to resolve overlapping the content of the webview here, but it was closed for some reason. But here is what happens. I have created a webview, applied transparent background, but when i try to load something, and reload something again, the older content will still remain on the webview and the newer one will overlap it. Here is a picture that explains it.

所以我创建一个玩笑应用程序,我增加了web视图。然后,我添加的透明度和随机笑话按钮重新加载网页,使web视图可以得到另一个笑话。但它只是overlapps代替。任何解决办法?这是我的一块code

So i am creating a jokes application, and i have added webview. Then i added transparency and the random joke button reloads the webpage so that the webview can get another joke. But it just overlapps instead. Any solutions? Here is my piece of code

        Button random = (Button) findViewById(R.id.reload);
    final WebView web = (WebView) findViewById(R.id.webView);
    web.setBackgroundColor(Color.TRANSPARENT);
    web.setWebViewClient(new WebViewClient());


    String selected = (String) getIntent().getCharSequenceExtra("selected");
    final String url = "http://someurl.com/?s=dirty&x=" + selected;
    web.loadUrl(url);

    random.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            web.loadUrl(url);
        }
    });

任何帮助将是非常美联社preciated:)

Any help would be really appreciated :)

推荐答案

试着做 web.loadUrl(URL)之前; web.clearView ();

请参阅文档

这篇关于Android的web视图内容重叠,而使用透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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