android - 如何在Android Studio中使图像中的特定颜色透明?
问题描述
我正在使用带有字母“LYIT”和白色背景的图像。我想让白色背景透明,所以只有字母可见。
我试过android:background="@android:color/transparent"
了,但它只改变了图像Logo的一小部分。
app:tint="@color/colorWhite"
也不行。
有没有办法可以定位图像的白色部分并使其透明?
另外,我正在用 Kotlin 编写我的课程。
谢谢
解决方案
我在另一个问题上找到了这个答案,您可以在后端编写以下代码
val image = findViewById<ImageView>(R.id.*write the id of the image here*)
image.background.alpha = 0 //the value of alpha's range is [0,255], 0is transperent and 255 is quite opaque
推荐阅读
- oracle - Solaris Client 8.1.7 无法连接到 Oracle 12C R1
- javascript - Google Drive 未加载 pdf 链接
- php - 在 php 中显示的总和值
- sql - 在 table1 中选择值、Group By、Sum 的存储过程,然后将这些值插入到 table2 中
- ios - 如何将 dateFormatter 值(例如 2019 年 7 月 7 日)从时间戳转换为 2019 年 7 月 7 日?
- python - 在 Python Pygame 中调用对象和传递变量不工作错误说变量未定义
- html - 自举对齐输入字段
- javascript - 如何将变量 js 发布到 Django
- javascript - 从匿名函数返回值时遇到问题
- antlr4 - 我可以让我的 ANTLR4 Lexer 从输入流中丢弃一个字符吗?