如何设置LinearLayout背景图像来填充屏幕



我有一个具有背景图像集的LinearLayout,我希望图像保持其长宽比,因为现在它被屏幕大小修改了。在xcode中,你可以设置imageView属性Aspect fill,但在eclipse中,我找不到这个问题的解决方案。这是我的LinearLayout xml:

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@drawable/bgapp"
        android:scaleType="centerCrop" >

对于这种情况,您有几个可绘制的文件夹,您需要在其中保存对应于各自设备尺寸的图像。即。HDPI -有不同的分辨率图像MDPI,XHDPI,XXHDPI是使用的各种dpi

的进一步信息,这里是链接,你可以得到确切的尺寸:http://developer.android.com/guide/practices/screens_support.html

我认为android:scaleType="fitXY"解决你的问题。请试一次

线性布局应该是这样的:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/bgapp" >

我在五天前有同样的问题,我通过在宽度高度上添加fill_parent来解决它,当我解决了我的问题时,我很惊讶。

最新更新