如何控制控件的大小呢? java
如何让imageView铺满屏幕呢?
昨天用相关布局试了很久,控件周围都和屏幕边缘没法彻底融合,经由同窗提醒,发现是布局的问题,选线性布局就没有这种问题啦。android
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/start" /> </LinearLayout>
那么要怎么实现几个图片控件铺满屏幕呢?布局
layout_weightspa
1.做用3d
是用来分配控件在布局中的比重的。只能在linearlayout中使用。code
2.使用方法xml
若属性为“warp_content",那么控件权重和其数值成正比。blog
若是为“match_parent”,和权值成反比。图片
使用范例如上。it
3.思考
如果一个有权重的碰到无权值的,该先知足谁呢?
答案是先知足无权值的。