1 / 6
文档名称:

高度-宽度属性.doc

格式:doc   大小:125KB   页数:6页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

高度-宽度属性.doc

上传人:文库旗舰店 2020/12/4 文件大小:125 KB

下载得到文件列表

高度-宽度属性.doc

相关文档

文档介绍

文档介绍:Android 中fill_parent与wrap_content的区别
  (2014-03-21 20:14:52)
转载▼
标签: 
fill_parent与wrap_co
 
it
分类: Android笔记
在Android中,对于组件的属性“layout_width”和“layout_height”,
其值总是设置为“wrap_content”或“fill_parent”。
那么,这两个值有什么不同呢?  请看下面的定义:  
1. wrap_content:组件的大小以能装入其内容即可; 
 2. fill_parent:组件会显示得和其父组件一样大,并填充剩余的空间(在 API Level 8中命名为 match_parent)。
eg:

 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="***@string/hello_world" />
   
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="FINISH"/>
放置一个Button组件,并设置其宽度和高度为wrap_parent,这会告诉Android将按钮显示为能够装下其内容。

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="***@string/hello_world" />
   
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="FINISH"/>
将layout_width的值改为fill_parent,现在按钮的宽度填充了剩余的空间,与其父组件Textview的宽度一样,单高度依然是保持在紧紧能容纳下内容。

 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="***@string/hello_world" />
   
        android:layout_width="wrap_content"
        android:layout_height