【发布时间】:2016-08-13 13:03:50
【问题描述】:
我得到了一个透明颜色的 png 图像,我想在一个 Android 应用程序的 ImageView 中使用它。 You can check that the image has a transparency color
我将图片添加到每个文件夹(drawable-mdpi、drawable-ldpi..) 并将 ImageView 与图像链接起来。 我没有得到透明色,而是得到了一个白色的,如下所示 The result 蓝屏是带背景的RelativeLayout。 这是 XML 代码:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/barre_puissance"
android:layout_toRightOf="@+id/barre_angle"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/bg_mr">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_mr_projectile"
android:layout_centerInParent="true"
/>
</RelativeLayout>
【问题讨论】:
-
图片右下角有一个黄色警告三角形。这是从哪里来的?
-
它说“图像缺少 contentDescription 属性”
-
我的意思是,您的布局中的哪个可绘制对象中有那个三角形?
-
imageView2,我刚刚添加了另一张图片,它工作正常,所以问题来自第一张图片,但是为什么?
-
用您的 Photoshop 重新制作。如果另一张照片的透明度很好,那么这张照片一定是搞砸了。
标签: android xml imageview transparency