三个控件,button1,web,button2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" > <Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button1"/>
<WebView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/but1"/>
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/web"
android:text="Button2" /></RelativeLayout>
因为加载的网页太大,button2不能显示
如何能让button1在顶部显示,button2在底部显示,而无论网页大小如何,WebView都只且占据两个button中间的空间?Android布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" > <Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button1"/>
<WebView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/but1"/>
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/web"
android:text="Button2" /></RelativeLayout>
因为加载的网页太大,button2不能显示
如何能让button1在顶部显示,button2在底部显示,而无论网页大小如何,WebView都只且占据两个button中间的空间?Android布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Button" /> <Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Button" /> <WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button2"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button1" /></RelativeLayout>
button1
android:layout_alignParentTop="true"button2
android:layout_alignParentBottom="true"webview
android:layout_below="@+id/button1"
android:layout_above="@+id/button2"
让webView有属性android:layout_above="@id/button2"
这样只需给WebView加一个layout_weight=1即可,它占据剩下的布局空间