如何在Android上使背景20%透明

本文翻译自:How to make a background 20% transparent on Android

我如何使Textview的背景大约20%透明(不完全透明),背景中是否有颜色(即白色)?


#1楼

参考:https://stackoom.com/question/lLzd/如何在Android上使背景-透明


#2楼

Use a color with an alpha value like #33------ , and set it as background of your editText using the XML attribute android:background=" " . 使用具有#33------这样的alpha值的颜色,并使用XML属性android:background=" "将其设置为editText的android:background=" "

  1. 0% (transparent) -> #00 in hex 0%(透明)->#00(十六进制)
  2. 20% -> #33 20%->#33
  3. 50% -> #80 50%->#80
  4. 75% -> #C0 75%->#C0
  5. 100% (opaque) -> #FF 100%(不透明)-> #FF

255 * 0.2 = 51 → in hex 33 255 * 0.2 = 51→十六进制33


#3楼

Make the color have 80% in the alpha channel. 使颜色在Alpha通道中占80%。 For example, for red use #CCFF0000 : 例如,对于红色,请使用#CCFF0000

<TextView
   ...
   android:background="#CCFF0000" />

In the example, CC is the hexadecimal number for 255 * 0.8 = 204 . 在示例中, CC255 * 0.8 = 204的十六进制数。 Note that the first two hexadecimal digits are for the alpha channel. 请注意,前两个十六进制数字用于alpha通道。 The format

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值