`
从此醉
  • 浏览: 1044519 次
  • 性别: Icon_minigender_1
  • 来自: US
社区版块
存档分类
最新评论

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
<wbr><span style="font-size:18px"></span><wbr><span style="font-size:18px">Android2.2中match_parent和fill_parent是一个意思.两个参数意思一样,match_parent更贴切,于是从2.2开始两个词都可以用。那么如果考虑低版本的使用情况你就需要用fill_parent了</span></wbr></wbr>


分享到:
评论

相关推荐

    Android中measure过程、WRAP_CONTENT详解以及

    1、WRAP_CONTENT、MATCH_PARENT/FILL_PARENT初入Android殿堂的同学们,对这三个属性一定又爱又恨。爱的是使用起来挺爽地---照葫芦画瓢即可,恨的却是时常混淆这几个属性地意义,需要三思而后行。在带着大家重温下这...

    Android学习笔记

    有三个值match_parent、fill_parent、wrap_content. 其中match_parent和fill_parent的意义相同,但官方更推荐match_parent. match_parent表示让当前控件的大小和父布局的大小一样,也就是由父布局来决定当前控件的...

    viewpager相关

    android:layout_height="wrap_content" android:layout_gravity="center" &gt; &lt;android.support.v4.view.PagerTitleStrip android:id="@+id/pagertitle" android:layout_width="wrap_content" android:layout_...

    android顶部滑动导航

    android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F0EFF5" &gt; android:id="@+id/sayit_rl_tab" android:layout_width="fill_parent" android:layout_...

    星座说明书

    android:layout_height="fill_parent" &gt; android:id="@+id/launchimage" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; 3.1.3功能  主要功能:1.美化星座查询系统,吸引...

    移动终端应用开发题库

    B.fill_parent C.wrap_content D.match_content 3.对一些资源以及状态的操作保存,最好是保存在Activity生命周期的哪个函数中进行?B a.onStart() B.onPause() C.onCreate() D.onResume() 4.关于视图控件的常用...

    SwipeListViewTest项目

    &lt;TextView android:id="@+id/example_row_tv_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:textSize="18sp" /&gt; 这个布局...

    九宫格牌翻转游戏demo

    android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="2dp" android:text="猜猜是哪张" android:textSize="20sp" /&gt; android:id="@+id/button1" ...

    Android实现在xml文件中引用自定义View的方法分析

    本文实例讲述了Android实现在xml文件中引用自定义View的... android:layout_height=wrap_content &gt; 方法二: &lt;view class=com.test.copytext.CopyText android:layout_width=match_parent android:layout_height

    安卓zxing 代码demo

    android:layout_height="match_parent"&gt; android:id="@+id/second_button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center_...

    Android开发:TextView加入滚动条示例

    利用scrollview来实现,效果会好很多 代码如下: &lt;ScrollView android:id=”@+id/scrollView1″ android...TextView android:id=”@+id/ee_source” android:layout_width=”fill_parent” android:layout_height=”wrap

    应用启动页自定义跳转计时器View Demo

    import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics...

    CE中文版-启点CE过NP中文.exe

    Fill Memory: Now allows 64-bit addresses Structure Dissect: Fixed the popupmenu "change type" so it now affects all selected entries instead of just the first PointerOrPointee window: Fix the debug ...

Global site tag (gtag.js) - Google Analytics