Android的Layout及其Param

來源:互聯網
上載者:User
2009-08-22Android的Layout及其Param

 

ViewGroup.MarginLayoutParams

android:layout_marginBottom

android:layout_marginLeft

android:layout_marginRight

android:layout_marginTop

=====================================

ViewGroup.LayoutParams

android:layout_height

android:layout_width

=====================================

FrameLayout.LayoutParams

[ViewGroup.MarginLayoutParams]

[ViewGroup.LayoutParams]

=====================================

AbsoluteLayout.LayoutParams

[ViewGroup.LayoutParams]

layout_x

layout_y

=====================================

LinearLayout.LayoutParams

[ViewGroup.MarginLayoutParams]

[ViewGroup.LayoutParams]

android:layout_gravity

android:layout_weight

=====================================

RelativeLayout.LayoutParams

[android.view.ViewGroup.MarginLayoutParams]

[android.view.ViewGroup.LayoutParams]

android:layout_above

android:layout_alignBaseline

android:layout_alignBottom

android:layout_alignLeft

android:layout_alignParentBottom

android:layout_alignParentLeft

android:layout_alignParentRight

android:layout_alignParentTop

android:layout_alignRight

android:layout_alignTop

android:layout_alignWithParentIfMissing

android:layout_below

android:layout_centerHorizontal

android:layout_centerInParent

android:layout_centerVertical

android:layout_toLeftOf

android:layout_toRightOf

 

 

以上,[...]表示繼承關係

 

以上,羅列了各布局下的可用參數。

 

控制項的布局不同,體現在xml檔案中,其可用的參數(param)也有差異,且其子控制項(寫在該布局下的控制項)。

 

比如,同樣是TextView,當布局為LinearLayout時,它的可用的layout參數有9種,而布局為AbsoluteLayout時,它的可用的layout參數只有4種。(當然不同版本的sdk可能會有所差異)。

 

甚至LinearLayout和AbsoluteLayout內幕就沒有相同的layout屬性。

 

他們之間的比較可以查看附件裡的圖片,相信大家都會一目瞭然。

 

布局應用中控制項裡幾乎無處不在,瞭解什麼情況下用什麼布局及布局屬性,還是很有必要的。

所以,如果在布局不同的情況下,直接進行複製子控制項操作很有可能出問題。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.