如何区别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="传递数据" />
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="传递数据" />
版权声明:本站【趣百科】文章素材来源于网络或者用户投稿,未经许可不得用于商用,如转载保留本文链接:https://www.qubaik.com/life/2377.html