作者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