Android Studio和.png矢量图片

时间:2015-05-17 07:25:33

标签: android vector

在Photoshop中创建矢量图像(用于透明背景)。当我将它们添加为我的ImageButtons的图像源并运行应用程序时,图像显示为白色背景。

无法通过应用找到有关图片未透明的原因的有用信息。

是否需要一些额外的步骤/编码才能使矢量图像正常工作?我无法理解为什么,但如果您有任何信息,我们将不胜感激!

- 谢谢你

示例代码,按要求:

<ImageButton
    android:id="@+id/btnGameUp"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:src="@drawable/arrowright"
    android:adjustViewBounds="false"
    android:clickable="true"
    android:cropToPadding="false"
    android:padding="0dp"
    android:scaleType="fitXY"
    android:layout_marginLeft="270dp"
    android:layout_marginTop="260dp" />

1 个答案:

答案 0 :(得分:0)

没有人来帮助我们,但是我们在哭泣几小时之后找到了解决方案并且互相抱着以获得舒适。

在布局xml文件中,您需要将以下行添加到每个矢量对象:

android:background="@android:color/transparent"

就是这样!经过测试和完美运作。希望这有助于某人。