调整可绘制图层列表2中的位图大小

时间:2013-02-06 16:24:19

标签: android android-activity styles

如何缩放像android这样的位图:scaleType =“fitCenter”?

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/gradient"/>
    <item android:bottom="60dip">
        <bitmap
                android:gravity="center_horizontal|bottom"
                android:src="@drawable/image"/>
    </item>
</layer-list>

我有680x120像素的图像,图像不适合小屏幕。我一直在尝试重力,但它没有帮助我(例如,我看到图像240x120,但不是240x42)。我将此样式用于活动背景,我不能使用ImageView。

2 个答案:

答案 0 :(得分:0)

如果您不使用&lt; LinearLayout&gt; 尝试将其与您的方法一起使用。

答案 1 :(得分:0)

这里同样的问题,但我用重力填充水平解决了这个问题,第二个最重要的是你必须使用方形图像/ png像240p X 240p然后图片将自动调整大小到它的屏幕。

<item
    android:drawable="@drawable/back">

</item>

<item>
        <bitmap
            android:gravity="fill_horizontal"

            android:tileMode="disabled"
            android:src="@drawable/logo"/>

</item>

相关问题