1

I am trying to add a WebView and some other TextViews in a ScrollView. It works fine till the content size is small. But when the content increases (which is to be loaded in WebView), it throws an error saying:

View too large to fit into drawing cache, needs 'x' bytes, only 'y' available".

I tried all different flags and all answers on StackOverflow which I could find, but still unable to solve the issue. Is there a way to have a WebView inside ScrollView or not?

I can't use hardwareAccelerated flag, it makes the whole Activity slow.

Sufian
  • 6,405
  • 16
  • 66
  • 120
sanjeev
  • 1,343
  • 3
  • 16
  • 28
  • You should turn off HardwareAcceleration and try once again, check this http://stackoverflow.com/a/21145043/1237175 – Ramesh_D Jun 19 '14 at 04:59
  • I mentioned that I cannot turn off HardwareAcceleration as it makes the complete activity slow. – sanjeev Jun 19 '14 at 05:01
  • 3
    If you put your web view in scrollview then it might be not work. Because web view has its own scrolling functionality so this is not working. – Piyush Jun 19 '14 at 05:04
  • It works for smaller content. so that's not the problem. I found a solution myself, posting it as an answer please check. – sanjeev Jun 19 '14 at 05:13

3 Answers3

5

To make it work, I set ScrollView and WebView property:

android:layerType="software"
Sufian
  • 6,405
  • 16
  • 66
  • 120
sanjeev
  • 1,343
  • 3
  • 16
  • 28
1

Make the WebView Height and Width as wrap_content. And Use ScrollView For whole layout page so that your TextViews can be visible.

Sufian
  • 6,405
  • 16
  • 66
  • 120
Krupa Patel
  • 3,309
  • 3
  • 23
  • 28
1

You can use wrap_content or fill_parent for width and height in the XML.

Sufian
  • 6,405
  • 16
  • 66
  • 120
Maddy
  • 21
  • 7