关于Layout的开发细节

我们申明Layout有2中方式:
1.Declare UI elements in XML
2.Instantiate layout elements at runtime

直接用xml申明的布局文件可以很好的将程序logic跟程序界面元素分开,每一个
layout文件都必须包含一个root element(View or ViewGroup),当然每一个View
or ViewGroup都有自己相应的View属性设置.

每一个View都可能需要设置一个自己的id:
android:id="@+id/my_button"
symbol (+) means that this is a new resource name that must be created
and added to our resources (in the R.java file)

When referencing an Android resource ID, 我们不需要添加+,但必须添加android
包命名空间like so:android:id="@android:id/empty"

在xml中定义组件元素的时候,都必须有(layout_width and layout_height)属性,
Many LayoutParams also include optional margins and borders

"wrap_content":自适应显示内容的尺寸
"fill_parent" (match_parent in API Level 8)填满父View显示区域

一个View有2中宽,高度
1.The first pair is known as measured width and measured height.
These dimensions define how big a view wants to be within its parent
2.The second pair is simply known as width and height
These dimensions define the actual size of the view on screen

里面内容有些怕自己翻译不准确,所以就直接贴上了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值