zoukankan      html  css  js  c++  java
  • Android连载41-复习四种基本布局

    详解四种基本布局

    LinearLayout

    • 线性布局
    • android:orientation=
      • vertical 垂直排列
      • horizontal 水平排列
    • android:layout_gravity= 用于指定文字在控件中的对齐方式
      • top
      • center_vertical
      • bottom

    注意若orientation是horizontal,那么控件只能是垂直方向上的对齐 若orientation是vertical,那么控件只能是水平方向上的对齐

    • android:layout_weight 这是一种比例,比如我们有两个控件,都指定了layout_weight=1,那么它们在水平方向上按照1:1的比例平分了水平方向的长度,此时我们指定layout_width多少都无效了

    RelativeLayout

    • 相对定位
    • 常见属性alignParentRight,alignParentLeft,centerInParent,alignParentBottom,alignParentTop,layout_above,layout_toLeftOf,layout_below,layout_toRigthOf,layout_alignTop,layout_alignBottom,layout_alignRight和layout_alignLeft

    FrameLayout

    • 所有的控件都会摆放在布局的左上角

    TableLayout

    • TableRow就是在表中加了一行,没加入一个控件就代表加入了一列,使用layout_span可以进行横跨某几列
    • 在TableRow无法指定控件的宽度,这时候使用android:stretchColumns属性就可以很好的解决这个问题,它允许将TableLayout中的某一列进行拉伸,以达到自动适应屏幕宽度的作用.
    • 指定为数字1就代表如果表格不能占满整个屏幕,那么就将第二列拉伸,如果指定成1,那么就是拉伸第一列
  • 相关阅读:
    Swift-自定义类的构造函数
    Swift-存储属性,计算属性,类属性
    iOS-UICollectionViewController协议及回调
    Swift-数组
    Swift-switch使用注意点
    Swift-setValuesForKeysWithDictionary
    解决IDEA Struts2 web.xml问题
    枚举类
    增强for循环 -- foreach循环
    静态导入
  • 原文地址:https://www.cnblogs.com/ruigege0000/p/15092503.html
Copyright © 2011-2022 走看看