Android fill_parent和wrap_content分析
来源:互联网 发布:ae cc软件下载mac 编辑:程序博客网 时间:2024/05/29 12:35
三个属性都用来适应视图的水平或垂直大小,一个以视图的内容或尺寸为基础的布局比精确地指定视图范围更加方便。
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了
1. wrap_content
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/btnButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button CJP"/>
</RelativeLayout>
2. fill_parent – width
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/btnButton1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button CJP"/>
</RelativeLayout>
3. fill_parent – height
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/btnButton1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button CJP"/>
</RelativeLayout>
4. fill_parent – width, height
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/btnButton1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button CJP"/>
</RelativeLayout>
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android fill_parent和wrap_content分析
- Android下fill_parent/match_parent和wrap_content分析
- Android fill_parent和wrap_content分析 (转)
- Android fill_parent、wrap_content和match_parent
- Android fill_parent和wrap_content理解
- Android之fill_parent和wrap_content
- Android的fill_parent和wrap_content
- Android fill_parent、wrap_content和match_parent的区别
- Android fill_parent、wrap_content和match_parent的区别
- android之视频播放插件的选择
- SIFT特征
- virt-manager 创建network interface (bridge、vlan、bond等)后,启动出错问题原因
- Android 3D旋转动画效果
- firefox快捷键
- Android fill_parent和wrap_content分析
- OCP-1Z0-053-V12.02-352题
- mysql中去除重复4步骤
- 九度OJ 题目1543:无限完全二叉树的层次遍历
- flume ng 1.3 安装配置方法
- 排序算法之选择排序
- linux下vi命令大全
- eclipse插件HotSpot Launcher:用于配置jvm参数
- 有两个浮点数a,b,计算a/b,要求保留小数点后面n 位(我写出小数点只能保存9~15位有效位数)