[英]Load webview with large content in a scrollview in android
I am trying to add a WebView
and some other TextView
s in a ScrollView
. 我试图在
ScrollView
添加WebView
和其他一些TextView
。 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: 但是当内容增加(将在
WebView
加载)时,它会抛出错误说:
View too large to fit into drawing cache, needs 'x' bytes, only 'y' available".
视图太大而无法适应绘图缓存,需要'x'字节,只有'y'可用“。
I tried all different flags and all answers on StackOverflow which I could find, but still unable to solve the issue. 我在StackOverflow上尝试了所有不同的标志和所有答案,但我仍然无法解决问题。 Is there a way to have a
WebView
inside ScrollView
or not? 有没有办法在
ScrollView
使用WebView
?
I can't use hardwareAccelerated
flag, it makes the whole Activity
slow. 我不能使用
hardwareAccelerated
标志,它使整个Activity
变慢。
为了使它工作,我设置ScrollView
和WebView
属性:
android:layerType="software"
Make the WebView
Height and Width as wrap_content
. 将
WebView
高度和宽度设置为wrap_content
。 And Use ScrollView
For whole layout page so that your TextView
s can be visible. 并使用
ScrollView
对于整个布局页面,以便可以看到TextView
。
您可以在XML中使用wrap_content
或fill_parent
作为宽度和高度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.