dorbt12
dorbt12

Reputation: 139

WebView not wraping content

I can't make my WebView wrap the displayed content. The problem is that the WebView width is all the screen, while the height is about 300px. How can I make it wrap content and be like the file suppose to be?

Here is my current layout XML:

 <WebView
  android:id="@+id/animation_1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />

Upvotes: 3

Views: 5228

Answers (2)

Irshad Khan
Irshad Khan

Reputation: 784

Please follow this link this

here it is mention that WebView has bug namely "Wrap content sized webview does not decrease size when the content size decreases"

Upvotes: 2

Mr.Me
Mr.Me

Reputation: 9286

Webview is built to render HTML pages which doesn't have size. so there is no way for it to determine something that doesn't exist and re-size according to it the same way say an ImageView resizes when the src image has changed.

Your best choice is to set the size of the webview to a fixed value maybe with weight and the user will have to scroll inside it when the page is bigger than the webview itself.

Upvotes: 4

Related Questions