• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to remove the white space in web view

aptgopal

Newbie
Dec 7, 2010
22
0
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
 
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.
 
Upvote 0
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!
 
  • Like
Reactions: sateeshpv
Upvote 0
Thank You. It helped me to solve.



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!
 
  • Like
Reactions: Unforgiven
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones