Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7001095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:45:32+00:00 2026-05-27T20:45:32+00:00

I want to create a WebView to display an image. But on the second/third

  • 0

I want to create a WebView to display an image.

But on the second/third start of the application WebView is empty on real devices.

When I comment out //wv.getSettings().setJavaScriptEnabled(true); then all is good and when in .http I am deleting onload="resize(this);" an app is starting with image every time too.

How to correct this. How to use JavaScript and don’t to have empty WebView?

Maybe I need to save the cache after first initialisation?

public class TestwebViewimageActivity extends Activity {
private WebView wv;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    wv = (WebView) findViewById(R.id.webview);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.setWebViewClient(new HelloWebViewClient());  
    wv.setBackgroundColor(0x00000000);
    wv.getSettings().setBuiltInZoomControls(false);
    wv.setVerticalScrollBarEnabled(false);
    wv.setHorizontalScrollBarEnabled(false);
    wv.loadUrl("file:///android_asset/4.html");
}

private class HelloWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}
}

my .html mast show image in full window:

<html><head>
</head>
<body>
<img src="myimage.png" onload="resize(this);" />
<script type="text/javascript">
function resize(image) {
    image.style['height'] = document.body.clientHeight + 'px';
    image.style['width'] = document.body.clientWidth + 'px';

    image.style['margin'] = 0;
    document.body.style['margin'] = 0;
}
</script>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:45:33+00:00Added an answer on May 27, 2026 at 8:45 pm

    I can’t help thinking you’d be better off using CSS than JavaScript to resize your image.

    I made an example using the great background-size: contain; property that auto-scales the background so it fits within the div, I think this is what you were trying to achieve with your JavaScript.

    http://jsfiddle.net/4DNsL/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want create image animation , i have 50 images with png format now
I want to create a Java application bundle for Mac without using Mac. According
I want to create my Rails application with MySQL, because I like it so
I want to create an Image Stream like in the Facebook app Dashboard. Where
I want to load a webview without cache? //Create a URL object. NSURL *url
hi i want to display my html image on android emulator, please help package
I want to create a jokes application where jokes can be voted up and
I have view that has a webview and a UIToolbar. I want to create
I need create WebView which can load a page from Youtube. I don't want
i want to create an android application in which i have to run ppt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.