[問題] 關於layout排版的問題

看板AndroidDev作者 (罪雲樵)時間12年前 (2012/08/15 18:44), 編輯推噓2(209)
留言11則, 4人參與, 最新討論串1/1
我排版如下: [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

08/15 21:38, , 1F
把r2與r3對調試試
08/15 21:38, 1F

08/16 09:53, , 2F
如果你是用eclipse寫的話,到xml的屬性裡面可以調
08/16 09:53, 2F

08/16 09:55, , 3F
你可以設定r2 BELOW r1, r2 ABOVE r1 這樣
08/16 09:55, 3F

08/16 09:59, , 4F
08/16 09:59, 4F

08/16 10:00, , 5F
如果是要在code裡面設定的話也可
08/16 10:00, 5F

08/16 10:01, , 6F
用layoutparameter.addrule
08/16 10:01, 6F

08/16 11:48, , 7F
我猜是r2的layout_height="fill_parent"造成的
08/16 11:48, 7F

08/16 11:55, , 8F
最外層可以改用LinearLayout,然後r1,r2,r3設layout_weight
08/16 11:55, 8F

08/16 11:58, , 9F
r1和r3設0,r2設1,這樣應該就可以了
08/16 11:58, 9F

08/16 12:04, , 10F
下午來試試,先謝謝上述回文的人^_^
08/16 12:04, 10F

08/16 15:58, , 11F
最後是用bukiya的方式,解決,謝謝大家!
08/16 15:58, 11F
文章代碼(AID): #1GAts1U4 (AndroidDev)