[英]How to make background transparent?
I am creating a background for a Textview object like this in XML: 我正在为XML中的Textview对象创建背景:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape android:padding="50dp"
android:shape="rectangle">
<gradient android:startColor="@color/sendDarkColor" android:endColor="@color/sendDarkColor" android:angle="90"/>
<stroke android:width="1dip" android:color="#FFFFFF"/>
<corners android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp" android:topLeftRadius="0dp" android:topRightRadius="0dp" />
</shape>
</item>
<item android:drawable="@android:color/transparent" />
sendDarkColor is just black. sendDarkColor只是黑色。 But I want this black to be transparent.
但是我希望这种黑色是透明的。 Similar to this: http://i.imgur.com/wzSeJTS.png
与此类似: http : //i.imgur.com/wzSeJTS.png
This xml is later is set to a Textview as mentioned. 如后所述,此xml稍后设置为Textview。 I want it be a little transparent.
我希望它有点透明。 How can I achieve this?
我该如何实现?
The color structure is like this AARRGGBB where AA is the alpha color in hexadecimal notation. 颜色结构类似于AARRGGBB ,其中AA是十六进制表示法中的alpha颜色。 For example, value for 50% transparency is #7FFFFFFF
例如,透明度为50%的值为#7FFFFFFF
To have black transparent color use: 要具有黑色透明色,请使用:
android:background="#50000000"
or just use the color "#50000000"
wherever you place a BG. 或在放置BG的任何地方都使用颜色
"#50000000"
。 The first two numbers after "#"
, sets the opacity/transparency of the color. "#"
之后的前两个数字设置颜色的不透明度/透明度。 Hope this helps. 希望这可以帮助。 Write if you don't understand something.
如果您不了解,请写信。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.