如何区别fill_parent和wrap_content



在Android布局文件中定义视图垂直或水平大小:

android:layout_width和android_layout_height的属性有fill_parent、wrap_content和match_parent

fill_parent、wrap_content和match_parent的区别:

1、wrap_content:表示大小刚好足够显示当前控件里的内容

        android:id="@+id/button1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentTop="true"

        android:text="传递数据" />

fill_parent和wrap_content 区别和使用效果_第1张图片

2、fill_parent和match_parent:

Android中fill_parent和match_parent(从Android2.2)是一样的。

为了兼容低版本,建议使用fill_parent

设置布局/控件为fill_parent将强制性让它布满整个屏幕或填满父控件的空白

 

        android:id="@+id/button1"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:layout_alignParentLeft="true"

        android:layout_alignParentTop="true"

        android:text="传递数据" />

fill_parent和wrap_content 区别和使用效果_第2张图片

更多相关文章

  1. android菜鸟学习笔记12----Android控件(一) 几个常用的简单控件
  2. android线性布局LinerLayout
  3. Android之获取加载图片宽高问题(getIntrinsicWidth与getwidth的区
  4. android view中invalidate和postInvalidate的区别
  5. Android 1.5 1.6 2.0 2.1 2.2 2.3 3.0,4.0的区别
  6. Android Studio 设置控件和颜色透明度
  7. Android 高级控件ExpandabledListView详解

随机推荐

  1. android简单的计算器
  2. Unity 生成Android(安卓)APK时报错 dupli
  3. android中jsoup解析html的几个例子
  4. Android(安卓)Studio 1.5.1更新说明与下
  5. Android(安卓)TTS学习――TTS初体验(中)
  6. Android(安卓)序列化
  7. Android(安卓)绘制折线和柱状图
  8. C#、Golang、Python、Java(Android)之间Des
  9. Android(安卓)sdk version and API level
  10. 仅layout使用继承TextView,报java.lang.Nu