Chinaunix首页 | 论坛 | 博客
  • 博客访问: 137527
  • 博文数量: 47
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 547
  • 用 户 组: 普通用户
  • 注册时间: 2014-09-01 08:57
个人简介

一个人的生活 新奇视 新感觉 www.x74.cn

文章分类

全部博文(47)

文章存档

2018年(20)

2017年(25)

2015年(1)

2014年(1)

我的朋友

分类: Android平台

2017-11-20 16:49:21

在Android中,总是把“wrap_content“或”fill_parent“组件属性”layout_width“和”layout_height“搞混?

看看下面的定义:

wrap_content–组件只想显示大到足以包围其内容只。
fill_parent–组件想要显示为大,填补剩余的空间。(后改名为match_parent在API级别8)
让我们看看下面的演示:

1。wrap_content
一个按钮元件,设置”wrap_content“在宽度和高度属性。它告诉Android显示按钮足够大,把它的内容”按钮ABC“只有。


"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

image.png

2。fill_parent–宽度
改变“layout_width“”fill_parent“,按钮的宽度将填补剩余的空间,因为”一样大相对布局”按钮的高度,但仍足以把它的内容。


"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

image.png

3.fill_parent–高度
改变“layout_height“”fill_parent“,按钮的高度将填补剩余的空间,因为”一样大相对布局”按钮的宽度,但仍足以把它的内容。


"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

image.png

4。fill_parent–宽度、高度
改变“layout_width“和”layout_height“”fill_parent”按钮将显示为整个设备的屏幕一样大,它只填满整个屏幕空间。


"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

image.png

原文博客地址:http://www.apkbus.com/blog-919651-76525.html
事实上,你可以指定一个确切的宽度和高度,但这是不推荐的,由于Android设备的各种屏幕尺寸。你只是不知道什么尺寸的Android设备上运行你的幻想中的应用。

阅读(6166) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~