线性布局的背景图像尺寸不是很好

问题描述:

我做了一个带有背景图像,PNG的线性布局...我不知道如何将它显示到布局(和居中)保持比例...这里是代码线性布局的背景图像尺寸不是很好

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/background"> 

显然图像具有相同的高度和宽度的显示...任何帮助?在此先感谢

= .4.S。=

+0

是图像被显示出来歪斜(错误的比例),不填充的LinearLayout的整个区域的问题,不居中,或者一些三者的结合? – plainjimbo 2011-06-06 20:48:42

+0

好吧,图像填充整个区域并居中,但比例错误,因为它锚定在布局上... – Erenwoid 2011-06-06 20:54:39

尝试此相关的问题/回答:

Android: Scale a Drawable or background image?

我还没有尝试过,但听起来类似于你在说什么。

如果你不想被拉伸你的图片,则可以使用BitmapDrawable重力为我们树立代替PNG的。
参考文档:Bitmap

谢谢大家^^我这样解决:

<?xml version="1.0" encoding="utf-8"?> 

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 


    <ImageView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/background" 
     android:layout_gravity="center"/> 


    <ListView android:id="@+id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:divider="#FFFFFF" 
     android:layout_weight="2" 
     android:drawSelectorOnTop="false" 
     android:layout_gravity="center"/> 

</FrameLayout>