WebView大小正在扩展,但根据其中的文本没有收缩

时间:2012-06-01 06:53:00

标签: android webview

我正在使用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会提供额外的空白空间而不会根据数据收缩,但如果我将方向更改为横向,则空白区域会减少... Plz解释我的观点发生了什么,我怎样才能减少额外的空白区域... ...提前... ...

1 个答案:

答案 0 :(得分:3)

布局中的Android属性 android:layout_weight = "1应该有效...