How to remove the white space in web view


  1. aptgopal

    aptgopal Member

    Hi
    I am developing a android application .In that i am displaying a web page in web view the web page contains only one image
    The problem is the web view displaying the image in the center and the other places in web view will be blank(white)
    I want to remove the white space to display only the image in the web view
    Is their any possibility means explain me

    Thanks in advance

    Advertisement
    :
  2. servicefly

    servicefly Member

    I too am interested. look forward to the solution.

    So far to remove the white space, I have created an image to the largest screen size (EVO) and made the primary objects in the image display in the center within a 480x320 area. Of course this creates another problem:

    My image (webpage) now opens in the webview aligned to top left instead of centered!

    If I find the solution, i will post it here too.
  3. servicefly

    servicefly Member

    I have solved this issue after two days of research; trial & error!

    1st, understand that the primary reason for the white space is usually the template or web page width is not equal to image width. For example, I had and image with a 800px width, but the template was 854px wide. Once I matched them I still wasn't out of the woods.

    Basically your html meta tag "viewport" is very important!
    link: Targeting Screens from Web Apps | Android Developers
    I underestimated its importance.

    Next you have to lock in your landscape or vertical for the activity in your source java file:
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    Swap LANDSCAPE for PORTRAIT for vertical.

    The following are also important:

    engine1.getSettings().setUseWideViewPort(true);
    engine1.setInitialScale(1);

    This should get you where you need to go. Hope it helps!
Loading...

Share This Page