【发布时间】:2012-06-01 06:52:59
【问题描述】:
我正在使用 WebView 来显示解析的 XML 和 HTML 内容。我已将 webview 的 layout_height 设置为 wrap_content。当物质很大时它工作得很好,但是当物质很小时它不会包裹到它下面的空间仍然是白色的。请告诉我每次更改 webView 中的内容时如何包装它。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background = "#ffffff"
>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background = "#ffffff" >
<WebView android:layout_height = "wrap_content"
android:layout_width = "wrap_content"
android:id = "@+id/webcontent"
/>
<LinearLayout android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:orientation = "horizontal"
android:id = "@+id/buttons"
android:background="#ffffff">
<Button android:layout_height = "wrap_content"
android:layout_width = "0dp"
android:id = "@+id/previousdata"
android:text = "Back"
android:layout_weight = "1"
android:layout_gravity="center_vertical"/>
<Button android:layout_height = "wrap_content"
android:layout_width = "0dp"
android:id = "@+id/nextdata"
android:layout_weight = "1"
android:text = "Next"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
现在我遇到的问题是,如果我在纵向模式下运行我的应用程序,webView 会提供额外的空白空间而不是根据数据收缩,但是如果我将方向更改为横向,空白空间会减少......请解释一下我的观点发生了什么,我怎样才能减少额外的空白......提前谢谢......
【问题讨论】:
-
这个链接也和下面一样,没有确切的解决方案...请找出一些正确的解决方案..thanx提前.. :)
-
你能发布你的布局 XML 吗?
-
@Anthony Atkinson:我已经发布了我的 xml,请告诉我解决方案。提前谢谢.. :)
-
现在我会遇到问题,如果我将视图从纵向更改为横向,它的设置是否正确......但每次我必须这样做......当内容发生变化时。