• Android成长日记-五大布局


    1. 五布局之线性布局LinearLayout

    特点:它包含的子控件将以横向或竖向的方式排列

    clip_image002

    ps:android:gravity=”center|bottom”(gravity允许多级联用)

    Tip:注意以下例子:

    1 <Button
    2 Android:layout_weight=”23 Android:layout_height=”wrap_parent”
    4 Android:layout_width=”match_parent”/>
    5 <Button
    6 Android:layout_weight=”17 Android:layout_height=”wrap_parent”
    8 Android:layout_width=” match _parent”/> 

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

     1 <Button
     2 
     3 Android:layout_weight=”2 4 
     5 Android:layout_height=”match_parent”
     6 
     7 Android:layout_width=”match_parent”/>
     8 
     9 <Button
    10 
    11 Android:layout_weight=”112 
    13 Android:layout_height=”match_parent”
    14 
    15 Android:layout_width=”match_parent”/>

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

    2. 五布局之相对布局RelativeLayout

    特点:它包含的子控件将以控件之间的相对位置或者子类控件相对父类容器的位置的方式排列

    clip_image004

    clip_image006

    Ps:

    clip_image008

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

    3.五布局之帧布局FrameLayout

    特点:在这个布局中,所有的子元素都不能被制定放置的位置,它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,将前面的子元素部分和全部遮挡。

    clip_image010

    Eg:通过FrameLayout设置类似进度条的效果

    clip_image011

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

    4.五布局之绝对布局AbsoluteLayout

    特点:又名坐标布局,可以直接指定子元素的绝对位置(XY)

    缺点:由于手机屏幕尺寸差别较大,使用绝对定位的适应性会比较差,在屏幕的适配上有缺陷

    clip_image013

    5.五布局之表格布局TableLayout

    特点:TableLayout表格布局模型以行列的形式管理子控件,每一行为一个TableRow的对象,当然也可以是一个View对象

    clip_image015

    ------------------------------------------------------------

    clip_image017

    ----------------------------------------------------------

    collapseColumns是设置隐藏,shrinkColumns是设置收缩,stretchColumns是设置填充空白。TableLaout列是从0开始计数


    [s1]这样的话上边的button占空间的2/3,下面的button1/3

    [s2]这样的话上边的button1/3,下面的button2/3

  • 相关阅读:
    管理者的存在 说明了企业文化的匮乏【20140124】
    Sublime Text2(ST2)点滴积累及使用技巧_持续更新【20130320】【最近修改20130516】
    WebStorm 点滴积累及使用技巧_持续更新【20130323】【最近修改20130604】
    码农,企业,和资本
    关于赛车游戏的一点体会
    从艺感悟
    三种糟糕的程序员
    关于ios单机盗版
    汽车加速性,功率和扭矩
    ExtJS之面向对象的概念
  • 原文地址:https://www.cnblogs.com/boy1025/p/4302019.html
Copyright © 2020-2023  润新知