Tuesday, October 19, 2010

Remove extra space on the right in the WebView

WebView is a very important element in Android. In mobile, people like to scroll everything such as contact list, email, webpage. However, didn't you realize that the scrolling is only in the vertical direction? This makes the user interface more friendly.

In WebView, you can scroll a webpage horizontally and vertically, but it is better to fix the horizontal bar by adjust the size of the contents so that the contents don't expand the View. I did that but I found there is some extra spaces in the WebView to make view scrollable horizontally. First, I think it is related to CSS and margin, so I add

* {margin:0px; padding: 0px;}

But it doesn't work. Finally, I realize that is the problem of the vertical scroll that occupies some spaces. To solve this problem, you can set the scrollbar style to display the scrollbars inside the content area.
webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

No comments:

Post a Comment