Android布局中match_parent和fill_parent的差别
今天在做项目的一个新功能的时候,从网上查找资源,发现android2.2中出现的MATCH_PARENT感到不明确。过去仅仅有FILL_PARENT和WRAP_CONTENT那么match_parent究竟是什么类型呢?
经过一番研究发现,从Android 2.2開始FILL_PARENT改名为MATCH_PARENT ,从API Level为8開始我们能够直接用MATCH_PARENT来取代FILL_PARENT,他们的定义本质是一样均为-1。仅仅是换了个别名,可能为了更准确些,比方终于在SDK中的定义为:
fill_parent -1 The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by match_parent.
match_parent -1 The view should be as big as its parent (minus padding). Introduced in API Level 8.
wrap_content -2 The view should be only big enough to enclose its content (plus padding).
从Android 2.2開始fill_parent改名为match_parent,从API Level 8能够直接用match_parent来取代fill_parent,只是2.2以后的版本号fill_parent仍然能够使用,他们的含义都是一样的,都是填满整个父窗体
三个属性都用来适应视图的水平或垂直大小,一个以视图的内容或尺寸为基础的布局比精确地指定视图范围更加方便。
1)fill_parent
设置一个构件的布局为fill_parent将强制性地使构件扩展,以填充布局单元内尽可能多的空间。
这跟Windows控件的dockstyle属性大体一致。设置一个顶部布局或控件为fill_parent将强制性让它布满整个屏幕。
2) wrap_content
设置一个视图的尺寸为wrap_content将强制性地使视图扩展以显示所有内容。以TextView和ImageView控件为例。设置为wrap_content将完整显示其内部的文本和图像。布局元素将依据内容更改大小。
设置一个视图的尺寸为wrap_content大体等同于设置Windows控件的Autosize属性为True。
3)match_parent
Android2.2中match_parent和fill_parent是一个意思 .两个參数意思一样。match_parent更贴切。于是从2.2開始两个词都能够用。
那么假设考虑低版本号的使用情况你就须要用fill_parent了
相关文章
- iOS中xib与storyboard原理,与Android界面布局的异同
- Android 判断手机是32位CPU还是64位CPU android.os.Build类字段含义
- libvlc android播放RTSP流视频的故事
- android常见错误-The container 'Android Dependencies' references non existing library
- Android WiFi开发教程(三)——WiFi热点数据传输
- Android中View绘制优化之一---- 优化布局层次
- Android Animation学习(四) ApiDemos解析:多属性动画
- Android应用程序窗口(Activity)的测量(Measure)、布局(Layout)和绘制(Draw)过程分析
- Android布局文件layout.xml的一些属性值
- Android控件进阶-自定义流式布局和热门标签控件
- android 传感器
- Android UI组件:布局管理器
- Android UI测量、布局、绘制过程探究
- Android Studio 与sdk下载安装
- Android 串口通信基于licheedev和android-serialport两种方案实现附Demo
- Android Developers:拖动和缩放
- Android App开发超实用实例 | 约束布局
- Android学习笔记之:android更新ui的几种经常用法
- 我的Android进阶之旅------>怎样在多个LinearLayout中加入分隔线
- Android回调事件传播-android学习之旅(四十五)
- 一个异常与Android Studio系列教程参考
- 从网上找的Android实用代码,记录备用
- Android:LinearLayout布局中Layout_weight的深刻理解