android布局--Android fill_parent、wrap_content和match_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了
总结:
match_parent和fill_parent的效果是一样的,不过是一个新一个旧罢了而且作用就是让控件布满整个屏幕
wrap_content的作用就是根据内容更改大小,将完整的显示其内容
- 浏览: 224740 次
- 性别:
- 来自: 江西
-
最新评论
-
闷骚的小老头:
这个和eclipse右什么区别么,都会啊这个
如何在Android Studio中创建一个selector.xml文件 -
闷骚的小老头:
导入Model就ok
如何在Android Studio中导SlidingMenu框架到项目中 -
gaojingsong:
七天玩转oracle,韩顺平玩转oracle,有些东西过时了, ...
oracle表的数据类型
相关推荐
有三个值match_parent、fill_parent、wrap_content. 其中match_parent和fill_parent的意义相同,但官方更推荐match_parent. match_parent表示让当前控件的大小和父布局的大小一样,也就是由父布局来决定当前控件的...
1、WRAP_CONTENT、MATCH_PARENT/FILL_PARENT初入Android殿堂的同学们,对这三个属性一定又爱又恨。爱的是使用起来挺爽地---照葫芦画瓢即可,恨的却是时常混淆这几个属性地意义,需要三思而后行。在带着大家重温下这...
android:layout_height="wrap_content" /> android:text="textview" android:textColor="#0000ff" android:layout_width="wrap_content" android:layout_height="wrap_content" /> ``` **2. LinearLayout...
例如,在上述示例中,三个按钮将会等宽分布。 #### 三、相对布局(RelativeLayout) 相对布局允许子视图相对于其他视图或者相对于父容器边缘定位。这使得布局更加灵活多样。例如: ```xml android:layout_width...
`wrap_content`用于使视图的大小适应其内容,而`match_parent`(等同于`fill_parent`)则使视图填充整个父容器。 通过以上介绍,我们可以看出,选择合适的布局类型对于优化用户界面至关重要。每种布局都有其独特的...
android:layout_height="wrap_content" /> android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" /> ``` TabWidget是显示...
- `Fill Mode`:指定子视图的尺寸,可以是具体的像素值、`wrap_content`(根据内容自动调整大小)或`fill_parent`(占据剩余空间)。 - `Weight`:权重属性,用于按比例分配子视图的大小。当多个子视图具有不同的...
android:layout_height="wrap_content" /> android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" /> ``` 接下来,我们需要在Activity的...
例如,如果有三个TextView,其中两个weight为1,它们将等比例扩展填充剩余空间,而第三个保持原样。以下是一个LinearLayout的示例: ```xml android:orientation="horizontal" android:layout_width="match_...
可以设置为`"fill_parent"`(占据父容器全部空间)、`"match_parent"`(与`"fill_parent"`等效)或`"wrap_content"`(根据内容自动调整尺寸)。 **1.2 示例代码** ```xml android:orientation="vertical" ...
android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/chun" /> android:id="@+id/imgView_xia" android:layout_width="match_parent" android:layout_height="wrap_...
android:layout_height="wrap_content" /> android:text="第二列" android:layout_width="0dp" android:layout_height="wrap_content" /> android:text="第三列" android:layout_width="0dp" android:...
为了实现多行显示,我们可以使用`RadioGroup`的`wrap_content`高度,并在每个`RadioButton`之间插入`View`或`Space`作为分隔符,然后通过设置它们的`layout_weight`属性来分配行宽。例如: ```xml android:layout...
android:layout_height="wrap_content" android:text="@string/hello" /> android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/editText1" android:inputType=...
android:layout_height="wrap_content" android:orientation="vertical"> android:id="@+id/header_image" android:layout_width="match_parent" android:layout_height="200dp" android:scaleType=...
- **android:layout_width** 和 **android:layout_height**:用于设定视图的宽高,可以选择`wrap_content`(视图自动调整大小以匹配内容)或`match_parent`(视图大小与父容器相同)。 **示例代码**: ```xml ...
android:layout_height="wrap_content" /> android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" /> ``` 接下来,我们要在代码中设置TabHost...
android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@drawable/handle"/> ``` Android 中的层 在 Android 中,有几层结构组成。第一层是壁纸,第二层是应用的 ...
android:layout_height="wrap_content" /> android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- 其他视图可以放在这里 --> ```...