How can I make a translucent toolbar in black I would like in quickPick enter image description here

    2 answers 2

    It is possible so:

    //установить прозрачность фону от 0 (прозрачно) до 255 (непрозрачно). toolbar.getBackground().setAlpha(125); 

    or so (for older versions of android, API <= 10):

     setAlphaForView(toolbar, 0.5f); private void setAlphaForView(View v, float alpha) { AlphaAnimation animation = new AlphaAnimation(alpha, alpha); animation.setDuration(0); animation.setFillAfter(true); v.startAnimation(animation); } 

    Thus, no extra. colors can be pushed into resources and transparency can be changed dynamically (for example, to make the Toolbar transparent when scrolling).

      toolbar.setBackgroundColor(getResources().getColor(R.color.my_color))

      • interested in the value of my_color - J Mas
      • whence there is a value in the resources <color name = "black_overlay"> # 66000000 </ color> it fits - J Mas
      • @YeldosTanikin Any of your color can be set in color.xml , or use this black_overlay . The color is specified in the format AARRGGBB where AA is alpha, transparency, RGB - Red, Green, Blue. The values ​​of any component vary from 00 to FF. For example, 00000000 is black completely transparent, FF000000 is black completely opaque. - anber
      • I was only interested in the code for such a color, thanks, from where this color came from in the resources it fits and I use it. - J Mas