Android 为什么不是';t视图展开以填充剩余空间
我想展开webview1视图以填充剩余空间。使按钮看起来始终位于屏幕底部。 我使用android:layout\u-weight属性为每个孩子分配一个权重。 但它似乎不起作用。我怎么做,有人能告诉我吗Android 为什么不是';t视图展开以填充剩余空间,android,attributes,autofill,Android,Attributes,Autofill,我想展开webview1视图以填充剩余空间。使按钮看起来始终位于屏幕底部。 我使用android:layout\u-weight属性为每个孩子分配一个权重。 但它似乎不起作用。我怎么做,有人能告诉我吗 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fi
<?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>
将weightSum=”“属性添加到线性布局中
因此,请使用以下命令,并根据需要使用wiegtSum和layout\u weight对其进行管理,同时使用LinearLayout而不是
标记
<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>
fill\u parent
/match\u parent
在ScrollView
中不起作用,原因很明显-如果它起作用,ScrollView
将无效
您的ScrollView
应该将fillViewPort
属性设置为true
。这使得ScrollView
的子级可以根据需要扩展到ScrollView
的高度。如果子项大于屏幕,则该属性无效。谢谢,我的意思是我想将WebView id/webview1扩展到剩余空间。现在,在通过URL内容加载webview之前,按钮显示在屏幕顶部。所以我想扩展webview,即使webview中没有内容