找回密碼
 立即註冊
查看: 1610|回復: 4

XML : ViewGroups

[複製鏈接]

938

主題

506

回帖

3萬

積分

管理員

網頁設計師

積分
31872

最佳新人活躍會員熱心會員推廣達人宣傳達人灌水之王突出貢獻優秀版主榮譽管理論壇元老

發表於 2016-7-8 18:20:07 | 顯示全部樓層 |閱讀模式
  1. <LinearLayout
  2.     android:orientation="vertical"
  3.     android:layout_width="wrap_content"
  4.     android:layout_height="wrap_content">

  5.     <TextView
  6.         android:text="Guest List"
  7.         android:layout_width="wrap_content"
  8.         android:layout_height="wrap_content" />

  9.     <TextView
  10.         android:text="Kunal"
  11.         android:layout_width="wrap_content"
  12.         android:layout_height="wrap_content" />

  13. </LinearLayout>
複製代碼


[發帖際遇]: redd 發帖時在路邊撿到 2 金錢,偷偷放進了口袋. 幸運榜 / 衰神榜

938

主題

506

回帖

3萬

積分

管理員

網頁設計師

積分
31872

最佳新人活躍會員熱心會員推廣達人宣傳達人灌水之王突出貢獻優秀版主榮譽管理論壇元老

 樓主| 發表於 2016-7-9 02:09:57 | 顯示全部樓層
xmlns : XML namespace declaration
  1. <LinearLayout
  2.     xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:orientation="horizontal"
  4.     android:layout_width="wrap_content"
  5.     android:layout_height="wrap_content">

  6.     <TextView
  7.         android:text="Guest List"
  8.         android:layout_width="wrap_content"
  9.         android:layout_height="wrap_content"
  10.         android:textSize="24sp"  />

  11.     <TextView
  12.         android:text="Redd"
  13.         android:layout_width="wrap_content"
  14.         android:layout_height="wrap_content"
  15.         android:textSize="24sp"  />

  16. </LinearLayout>
複製代碼
[發帖際遇]: 一個袋子砸在了 redd 頭上,redd 賺了 5 金錢. 幸運榜 / 衰神榜

938

主題

506

回帖

3萬

積分

管理員

網頁設計師

積分
31872

最佳新人活躍會員熱心會員推廣達人宣傳達人灌水之王突出貢獻優秀版主榮譽管理論壇元老

 樓主| 發表於 2016-7-9 02:10:53 | 顯示全部樓層
  1. android:orientation="vertical"
  2. android:orientation="horizontal"
複製代碼
[發帖際遇]: redd 樂于助人,獎勵 9 貢獻. 幸運榜 / 衰神榜

938

主題

506

回帖

3萬

積分

管理員

網頁設計師

積分
31872

最佳新人活躍會員熱心會員推廣達人宣傳達人灌水之王突出貢獻優秀版主榮譽管理論壇元老

 樓主| 發表於 2016-7-15 17:03:38 | 顯示全部樓層
parent view 可以這樣設定,長寬和手機螢幕一樣大:
  1. android:layout_width="match_parent"
  2. android:layout_height="match_parent"
複製代碼


child view 可以這樣設定:
  1. android:layout_width="match_parent"
  2. android:layout_height="wrap_content"
複製代碼
[發帖際遇]: redd 發帖時在路邊撿到 5 金錢,偷偷放進了口袋. 幸運榜 / 衰神榜

938

主題

506

回帖

3萬

積分

管理員

網頁設計師

積分
31872

最佳新人活躍會員熱心會員推廣達人宣傳達人灌水之王突出貢獻優秀版主榮譽管理論壇元老

 樓主| 發表於 2016-7-17 16:19:15 | 顯示全部樓層
  1. android:layout_weight="1"
複製代碼


LinearLayout also supports assigning a weight to individual children with the android:layout_weight attribute. This attribute assigns an "importance" value to a view in terms of how much space it should occupy on the screen. A larger weight value allows it to expand to fill any remaining space in the parent view. Child views can specify a weight value, and then any remaining space in the view group is assigned to children in the proportion of their declared weight. Default weight is zero.

For example, if there are three text fields and two of them declare a weight of 1, while the other is given no weight, the third text field without weight will not grow and will only occupy the area required by its content. The other two will expand equally to fill the space remaining after all three fields are measured. If the third field is then given a weight of 2 (instead of 0), then it is now declared more important than both the others, so it gets half the total remaining space, while the first two share the rest equally.
[發帖際遇]: redd 發帖時在路邊撿到 1 金錢,偷偷放進了口袋. 幸運榜 / 衰神榜
您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|小黑屋|DD論壇 維護: Redd Design

GMT+8, 2024-10-23 09:39 , Processed in 0.092992 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表