【问题标题】:Image background want to remove and set into transparent image图像背景要删除并设置为透明图像
【发布时间】:2018-07-20 05:04:48
【问题描述】:
     [It is a sticker app I want to remove image background white color, I need a transparent image][1]
      XML: Sticker view used for sticker adding in image view this sticker file going to save into phone gallery 
            <com.xiaopo.flying.sticker.StickerView
                android:id="@+id/sticker_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                app:showBorder="false"
                app:showIcons="false">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/cropped_image_view"
             />
 </com.xiaopo.flying.sticker.StickerView>

Java:我为贴纸视图和图像视图设置了背景透明,但我在图库中获得了黑色背景图像,有任何选项可以删除背景颜色并将图像设置为透明程序化,

stickerView.setBackgroundColor(getResources().getColor(R.color.transparent));
stickerView.setBackgroundResource(R.color.transparent);
imageView.setBackgroundResource(R.color.transparent);

【问题讨论】:

  • 提供更多细节。只有图片是不够的
  • 我添加了xml和源代码

标签: java android xml image


【解决方案1】:

在您的 XML 文件中,在 StickerView 属性中添加:

android:background="#00FFFFFF"

基本上#FFFFFF 是白色的,它可以是任何颜色,它是设置透明度的# 后面的两个0。 #00 表示 0 Alpha,因此完全透明。

这也适用于按钮。

【讨论】:

    猜你喜欢
    • 2019-02-08
    • 2012-05-31
    • 2013-02-03
    • 1970-01-01
    • 2021-12-31
    • 2011-12-23
    • 2016-12-08
    • 1970-01-01
    • 2011-12-06
    相关资源
    最近更新 更多