的WebView规模正在扩大,但不会收缩按照文本中它规模、WebView、文本中

2023-09-05 23:15:13 作者:月幕几许

我使用的WebView显示解析的XML和HTML内容。我设置web视图的layout_height到WRAP_CONTENT。它正常工作时,这个问题是体积大,但是当事情是小事就不用换到它下面的空间保持白色。请告诉我怎么每次换行,当我在web视图改变的内容。

I am using WebView to show parsed XML and HTML content. I have set the layout_height of webview to wrap_content. It works fine when the matter is large in size but when the matter is small it do not wrap to it the below space remains white. pls tell me how to wrap it each time when I change content in 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>

现在我得到这个问题,如果我运行在纵向模式我的应用程序web视图被给予额外的空白区域,而不是承包根据数据,但如果我的方向改变为横向的空白不减...... PLZ解释发生了什么,以我的看法,我怎么能减少提前多余的空白...感谢名单...

Now I am getting the problem that if I am running my app in portrait mode the webView is giving extra white space and not contracting according to the data, but if I change the orientation to landscape the white space diminished... Plz explain what's happening to my view and how can I diminish the extra white space... thanx in advance...

推荐答案

Android的特性: 的android:layout_weight =1 的布局应工作...

Android property: android:layout_weight = "1 in the layout should work...