`
kevin2562
  • 浏览: 116571 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Android UI

阅读更多
1. 一些常用的公共属性介绍

1) layout_width - 宽
    fill_parent: 宽度和父元素相同,wrap_content: 宽度随本身的内容所调整,或者指定 px 值来设置宽

2) layout_height - 高
    fill_parent: 高度和父元素相同,wrap_content: 高度随本身的内容所调整,或者指定 px 值来设置高

3) background - 设置背景图

4) padding - 设置边距
    可以具体设置paddingBottom,paddingLeft,paddingRight,paddingTop来设定不同的px值

5) id - 该object的id号
    @+id/id1 代表添加新的id名为id1, @id/id1 代表引用id1的控件

6) layout_weight - 重要度
     个人理解为显示的优先级。默认为0(最高),数值越大,优先级越低!参考下面的Linear Layout例子。要让layout_weight生效,需要父层或父父层的相应layout_width/layout_height = "fill_parent",否则wrap_content会压缩到最小足够空间!

7) layout_gravity - Container组件的对齐方式
     组件在layout里面的对齐方式。

8) gravity - 文字在组件里的对齐方式
    例如设置button里面的文字在button中居中显示。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics