如何让imageView铺满屏幕?

 如何控制控件的大小呢?  

 如何让imageView铺满屏幕呢?

  昨天用相关布局试了好久,控件周围都和屏幕边缘无法完全融合,经由同学提醒,发现是布局的问题,选线性布局就没有这种问题啦。

<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_weight

 1.作用

   是用来分配控件在布局中的比重的。只能在linearlayout中使用

 2.使用方法

   若属性为“warp_content",那么控件权重和其数值成正比。

   如果为“match_parent”,和权值成反比。

   

   使用范例如上。

   3.思考

     若是一个有权重的碰到无权值的,该先满足谁呢?

     答案是先满足无权值的。


猜你喜欢

转载自blog.csdn.net/xd15010130025/article/details/77206494