Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" />
like image 407
dorbt12 Avatar asked May 10 '26 10:05

dorbt12


1 Answers

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.

like image 126
Mr.Me Avatar answered May 13 '26 02:05

Mr.Me



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!