How do I make the background of a Textview
about 20% transparent (not fully transparent), where there is a color in the background (i.e. white)?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Here's a programmatic solution from @Aromero's answer to calculate the hexadecimal value for the alpha channel. :)
Use the below code for black:
Now if I want to use opacity then you can use the below code:
And below for opacity code: and all opacity level here
Hex Opacity Values
If you always to forget what code for transparency then you must have to see below link and no worry about to remember anything regarding transparent code :-
https://github.com/duggu-hcd/TransparentColorCode
There is an XML value
alpha
that takes double values.Since
API 11+
the range is from0f
to1f
(inclusive),0f
being transparent and1f
being opaque:android:alpha="0.0"
thats invisibleandroid:alpha="0.5"
see-throughandroid:alpha="1.0"
full visibleThat's how it works.
Alpha ranges between 0(transparent) and 1(opaque) in Android API 11+
See Popularity below textView using this
XML
Dynamically
btn.getBackground().setAlpha(128); // 50% transparent
tv_name.getBackground().setAlpha(128); // 50% transparent
android:alpha="0.38"
You can manage color opacity changing the first 2 characters in the color definition:
#99000000