【问题标题】:android ImageView doesn't show transparencyandroid ImageView 不显示透明度
【发布时间】: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


【解决方案1】:

Android XML 支持 png 文件的透明度,因此您的图像存在问题。 确保您的 png 图像文件包含透明度。

【讨论】:

  • 对 (y) ,这是图片,我用另一张替换了它,效果很好 (y) 感谢您的评论
  • 当我在清单上使用 android:hardwareAccelerated="true" 时,我失去了所有图像的透明度
猜你喜欢
  • 2011-06-22
  • 2016-12-02
  • 2012-03-25
  • 1970-01-01
  • 2014-10-22
  • 2016-09-17
  • 2012-01-17
  • 2014-03-20
  • 2015-06-18
相关资源
最近更新 更多