Android导航视图透明度 [英] Android Navigation View transparency
问题描述
每个人.是否可以使Navigation View
透明?
我有自定义布局,并尝试为此布局Navigation View
或Drawer Layout
设置50%的透明背景.
everyone. Is it possible to make Navigation View
transparent?
I have custom layout and try to set 50% transparent background for this layout, Navigation View
or Drawer Layout
.
android:background="#80000000"
但是它没有给出预期的结果.
but it doesn't give expected result.
有人尝试这样做吗?我将不胜感激.
Anybody tried to do this? I would appreciate help.
推荐答案
您可以尝试:
navigationView.getBackground().setAlpha(122);
在这里,您可以将不透明度设置为0(完全透明)到255(完全不透明)之间.
Here you can set the opacity between 0 (fully transparent) to 255 (completely opaque).
您还可以使用带双精度值的XML值alpha
.
you can also use XML value alpha
that takes double values.
范围是从0f到1f(包括0f),其中0f是透明的,而1f是不透明的:
The range is from 0f to 1f (inclusive), 0f being transparent and 1f being opaque:
android:alpha="0.0"
不可见
android:alpha="0.5"
透明
android:alpha="1.0"
完全可见
这篇关于Android导航视图透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!