【问题标题】:remove white background of image in android在android中删除图像的白色背景
【发布时间】:2015-03-02 22:20:19
【问题描述】:

我在 android 的框架布局内添加了一个内部图像。但问题是我得到了一个白色背景。我需要删除那个白色背景。任何帮助将不胜感激.....

截图如下

xml文件如下

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView  
        android:id="@+id/imageView"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:scaleType="center"
         />

    <ImageView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="left"
        android:background="@null"
        android:maxWidth="-5dp"  
        android:maxHeight="-5dp"
        android:src="@drawable/driveimg"
         />

</FrameLayout>

【问题讨论】:

  • 不,它没有透明背景
  • 仅出于测试目的将您的驱动器图像替换为 android 图标的默认图像,即 ic_launcher。查看结果。
  • 你使用的图片应该有透明背景...
  • 好吧,让我看看.....
  • 谢谢 Mike 和 A.R

标签: android image android-layout android-xml


【解决方案1】:

您可以将背景设置为 null (android:background="@null") 或使用透明颜色 (android:background="@android:color/transparent")

【讨论】:

  • 我已经添加了 android:background="@null" 并尝试 android:background="@android:color/transparent"...但没有发生任何变化
  • 表示驱动没有透明背景
  • @Miller,在我的情况下,一张图片出现在另一张图片下方,所以android:background 没有解决问题。那是带有uiSettings?.isMyLocationButtonEnabled = true 的谷歌地图。