简体   繁体   English

在android中的scrollview中加载大内容的webview

[英]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变慢。

为了使它工作,我设置ScrollViewWebView属性:

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_contentfill_parent作为宽度和高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM