开发者

Android Webview Content Overlapping While Using Transparent Background

开发者 https://www.devze.com 2023-03-13 03:03 出处:网络
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, appl

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.

Android Webview Content Overlapping While Using Transparent Background

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 pie开发者_Go百科ce 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);
        }
    });

Any help would be really appreciated :)


Try before doing web.loadUrl(url); doing web.clearView();

See docs.

0

精彩评论

暂无评论...
验证码 换一张
取 消