2013-08-03 42 views
0

我想展开webview1视图来填充剩余空间。使按钮看起来像总是在屏幕的底部。 我使用android:layout_weight属性为每个孩子分配一个权重。 但它似乎不起作用。我该怎么办呢,有谁能够告诉我什么为什么不是视图展开来填充剩余空间

<?xml version="1.0" encoding="utf-8"?> 

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <ScrollView style="@style/ScrollView" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:paddingBottom="8dp" 
      android:paddingLeft="12dp" 
      android:paddingRight="12dp" 
      android:paddingTop="8dp" > 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="0dp" 
       android:layout_marginTop="12dp" 
       android:orientation="vertical" 
       android:layout_weight="1" >  <---here assign a weight 

       <WebView 
        android:id="@+id/webview1" 
        **style="@style/update_text" />** 
      </LinearLayout> 

      <!-- h-line --> 

      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="12dp" > 

       <ImageView 
        android:id="@+id/line_end" 
        style="@style/form_h_line" /> 
      </RelativeLayout> 

      <!-- buttons --> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="12dp" 
       android:orientation="horizontal" > 

       <Space 
        android:layout_width="12dp" 
        android:layout_height="wrap_content"/> 

       <Button 
        android:id="@+id/button_ok" 
        style="@style/base_button" 
        android:layout_width="12dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="2" 
        android:text="OK"/> 

       <Space 
        android:layout_width="12dp" 
        android:layout_height="wrap_content"/> 
      </LinearLayout> 
     </LinearLayout> 
    </ScrollView> 

</FrameLayout> 

的原因是,因为它工作在的FrameLayout,所以webview1不能自动扩展。

+0

<空格代表什么? – KOTIOS

回答

0

fill_parent/match_parent不以ScrollView显而易见的原因,工作 - 如果它确实,ScrollView将是无用的。

您的ScrollView应该有fillViewPort属性设置为true。如果需要,这使得ScrollView的孩子扩展到ScrollView的高度。如果孩子大于屏幕,则该属性不起作用。

0

添加weightSum="" property to your LinearLayout

因此使用下面和管理它,只要你想with wiegtSum and layout_weight也使用的LinearLayout代替<Space>标签

 <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="12dp" 
      android:weightSum="3" 
      android:orientation="horizontal" > 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_weight="1" 
       android:layout_height="wrap_content"/> 

      <Button 
       android:id="@+id/button_ok" 
       style="@style/base_button" 
       android:layout_width="12dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="OK"/> 
      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_weight="1" 
       android:layout_height="wrap_content"/> 

     </LinearLayout> 
+0

谢谢,我的意思是我想将WebView id/webview1扩展到剩余空间。现在在通过URL内容加载webview之前,按钮显示在屏幕的顶部。所以我想扩展webview,即使webview中没有内容 – user2614801