查看过大,以适应在网页视图绘制缓存中滚动视图 [英] View too large to fit into drawing cache on Webview inside scrollview
问题描述
我在包含网页视图滚动型的工作,它的作品完美的2.3,4.1,但是当我尝试它的4.4模拟器,它显示
I am working on a scrollview that contain a webview, it works perfect on the 2.3, 4.1 , but when I try it on the 4.4 emulator, it show
View too large to fit into drawing cache, needs 5744640 bytes, only 3932160 available
web视图仅仅是空白。
The webview is just blank.
和它的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="@+id/newsTitle"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/last_update" />
<WebView
android:id="@+id/newsContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/last_update" />
<TextView
android:id="@+id/newsDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/last_update" />
</LinearLayout>
</ScrollView>
</LinearLayout>
我试图用 mywebView.setDrawingCacheEnabled(假);
,但它只是返回相同的警告
I tried to use mywebView.setDrawingCacheEnabled(false);
but it just return the same warning.
另外,我发现当网页是overscreen大小出现问题,但是当我表现出来,我在网上找到的布局略有不同,在2.3,4.1,它可以简单地启动新的生产线,如果这个词超过页面,然而,在4.4没有,所以字的一部分是在屏幕之外。
Also, I find the problem occur when the webpage is overscreen size , but when I show it , I find the layout of the web is slightly different, on 2.3 , 4.1 , it can simply start the new line if the word is exceed the page, however , in 4.4 it does not , so part of the word is out of the screen .
如何解决呢?谢谢
推荐答案
我的建议是给布局高度的WebView,这样它不会超过指定高度
My Suggestion is give layout height to webview so that it wont exceed the your specified height
<LinearLayout
android:id="@+id/webview1"
android:layout_width="fill_parent"
android:layout_height="150dip" >
<WebView
android:id="@+id/sampletxt"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
在您的活动只包含以下行
In your activity just include the below lines
SampleTxt.getSettings().setLoadWithOverviewMode(true);
SampleTxt.getSettings().setJavaScriptEnabled(true);
SampleTxt.loadData("Your Text To show the Webview",
"text/html; charset=UTF-8", null);
这将正常工作。任何疑问,让我知道
It will work fine. any doubts let me know
这篇关于查看过大,以适应在网页视图绘制缓存中滚动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!