Android 佈局

5種常用佈局:

  1. LinearLayout 線性佈局
    orientation:vertical 垂直 horizontal 水平

  2. RelativeLayout 相對佈局

    設置相對位置
    layout_center+InParent父佈局中央位置
    +Vertical父佈局垂直居中位置
    +Horizontal父佈局水平居中位置
    layout_+above/below/toLeftOf/toRightOf在某控件上/下/左/右
    layout_alignParentTop/Left/Right/Bottom與父控件上/左/右/下對齊
    layout_alignTop/Left/Right/Bottom與某控件的上/左/右/下對齊

    設置間距
    layout_marginTop/Left/Right/Bottom設置當前上/左/右/下邊界與某控件距離

    設置佈局內邊距
    padding 四周
    paddingTop/Left/Right/Bottom 上/左/右/下內邊距

  3. FrameLayout 幀佈局
    默認在屏幕左上角,按照放入順序重疊擺放。佈局大小由
    foreground 前景圖像,位於所有子控件之上
    foregroundGravity 設置前景圖像顯示位置

  4. TableLayout 表格佈局 extends LinearLayout
    配合TableRaw控件(行)使用,表格列數由包含最多控件的TableRaw決定

    佈局屬性:
    stretchColumns 設置該列被拉伸
    shrinkColumns 設置該列被收縮
    collapseColumns 設置該列被隱藏

    控件屬性:
    layout_column 設置單元格顯示位置
    layout_span 設置單元格佔幾行(默認1行)

  5. AbsoluteLayout 絕對佈局
    左上角爲原點。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章