Search code examples
androidnavigation-drawertransparencynavigationview

Android Navigation View transparency


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.


Solution

  • you can try:

    navigationView.getBackground().setAlpha(122);
    

    Here you can set the opacity between 0 (fully transparent) to 255 (completely opaque).

    you can also use XML value alpha that takes double values.

    The range is from 0f to 1f (inclusive), 0f being transparent and 1f being opaque:

    android:alpha="0.0" invisible

    android:alpha="0.5" see-through

    android:alpha="1.0" full visible