use*_*104 8 android scrollview webview
我正在使用包含webview的scrollview,它在2.3,4.1上工作得很完美,但是当我在4.4模拟器上尝试它时,它显示
View too large to fit into drawing cache, needs 5744640 bytes, only 3932160 available
Run Code Online (Sandbox Code Playgroud)
webview只是空白.
这是布局
<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>
Run Code Online (Sandbox Code Playgroud)
我尝试使用,mywebView.setDrawingCacheEnabled(false);但它只是返回相同的警告.
此外,我发现当网页超大屏幕时会出现问题,但是当我显示它时,我发现网页的布局略有不同,在2.3,4.1中,如果单词超出页面,它可以简单地启动新行然而,在4.4它没有,所以这个词的一部分是在屏幕之外.
怎么解决?谢谢
我的建议是给webview提供布局高度,这样它就不会超过你指定的高度
<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>
Run Code Online (Sandbox Code Playgroud)
在您的活动中,只需包含以下行
SampleTxt.getSettings().setLoadWithOverviewMode(true);
SampleTxt.getSettings().setJavaScriptEnabled(true);
SampleTxt.loadData("Your Text To show the Webview",
"text/html; charset=UTF-8", null);
Run Code Online (Sandbox Code Playgroud)
它会工作正常.任何疑惑让我知道
| 归档时间: |
|
| 查看次数: |
5675 次 |
| 最近记录: |