Android背景图片填充屏幕

时间:2012-05-21 04:00:24

标签: android android-layout

如何让我的相对布局显示我的图像视图:

enter image description here

而不是这个?:

enter image description here

我希望我的布局尽可能多地显示图像并裁剪图像的外部,例如当您在桌面中将桌面背景图像设置为“填充”时:

enter image description here

到目前为止我的xml布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:fitsSystemWindows="true" android:alwaysDrawnWithCache="false">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" android:src="@drawable/background_race_light"/>

    <LinearLayout
        android:id="@+id/linearLayout1"
        style="@style/SessionResumeBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/home_resumeSessionBar_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Button
            android:id="@+id/home_resumeSessionBar_buttonResume"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Resume" />
    </LinearLayout>





</RelativeLayout>

3 个答案:

答案 0 :(得分:30)

为您的imageview添加比例类型。有几种类型。你需要的是

android:scaleType="center"

page将有助于解释所有不同的类型。

答案 1 :(得分:5)

ImageView布局参数设置为match_parent,并将比例类型设置为适合您需求的比例类型:

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:scaleType="centerCrop"
    android:layout_alignParentTop="true" android:src="@drawable/background_race_light"/>

答案 2 :(得分:0)

scalexy = true

中设置ImageView
相关问题