作者terrybob (罪云樵)
看板AndroidDev
标题[问题] 关於layout排版的问题
时间Wed Aug 15 18:44:12 2012
我排版如下:
[RelativeLayout](r)
[RelativeLayout 1](简称r1)
[RelativeLayout 2](简称r2)
[RelativeLayout 3](简称r3)
我用r去包住r1、r2、r3。r1跟r3是放置按钮,而r2我放了webview显示网站内容。
手机去显示版面时,目标是要达到r1、r3是切开来的,就是r2的显示内容,
是不会被r1、r3档到。
目前显示是r1不会档,r3会档到r2的下半部…
xml码如下:
----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/Relat"
android:layout_gravity="bottom"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rel_01"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/buttonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/btn_color"
android:textColor="@color/white"
android:text="返回" />
<Button
android:id="@+id/buttonRefesh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/btn_color"
android:textColor="@color/white"
android:text="重整" />
<Button
android:id="@+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/buttonBack"
android:background="@drawable/btn_color"
android:textColor="@color/white"
android:text="首页" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rel_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/rel_01">
<android.webkit.WebView
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rel_03"
android:background="@color/black"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true">
<Button
android:id="@+id/buttonGuest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="留言" />
</RelativeLayout>
</RelativeLayout>
------------------------------
以上,谢谢。^_^
--
习惯一个人在房间里,安静地享受书的内容…
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.75.186.7
1F:→ asilzheng:把r2与r3对调试试 08/15 21:38
2F:推 namejoshua:如果你是用eclipse写的话,到xml的属性里面可以调 08/16 09:53
3F:→ namejoshua:你可以设定r2 BELOW r1, r2 ABOVE r1 这样 08/16 09:55
5F:→ namejoshua:如果是要在code里面设定的话也可 08/16 10:00
6F:→ namejoshua:用layoutparameter.addrule 08/16 10:01
7F:推 bukiya:我猜是r2的layout_height="fill_parent"造成的 08/16 11:48
8F:→ bukiya:最外层可以改用LinearLayout,然後r1,r2,r3设layout_weight 08/16 11:55
9F:→ bukiya:r1和r3设0,r2设1,这样应该就可以了 08/16 11:58
10F:→ terrybob:下午来试试,先谢谢上述回文的人^_^ 08/16 12:04
11F:→ terrybob:最後是用bukiya的方式,解决,谢谢大家! 08/16 15:58