Android XML图像的全宽

时间:2012-04-22 20:19:57

标签: android xml layout width

我的xml文件有问题,我希望background_bar采用全屏宽度(在屏幕顶部),但我不能这样做..请帮帮我 这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >

 <RelativeLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/main_background_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/background_bar"/>

    <ImageView
        android:id="@+id/main_logo_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="5dp"
        android:src="@drawable/logo_bar" />

    <ImageView
        android:id="@+id/main_title_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="27dp"
        android:layout_toRightOf="@+id/main_logo_bar"
        android:src="@drawable/notifme_title_bar" />

    </RelativeLayout>
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

尝试将android:scaleType="fitXY"或其中一个变体添加到background_bar。