Custom Translucent Android ActionBar

前端 未结 7 1022
梦如初夏
梦如初夏 2020-11-29 16:19

I\'ve been scouring the interwebs (e.g. Android documentation, answers here, etc.) for the answer to what I thought would be a fairly trivial question. How do you achieve a

7条回答
  •  感情败类
    2020-11-29 16:37

    I just like to share with you the steps I took to achieve this:

    1) At the OnCreate of your activity,

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    

    then

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    

    This is done before setContentView.

    2) After setContentView, you can do the following

     getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.argb(0, 100, 181, 246)));
    

    Where the alpha value of 0 means it is fully transparent.

提交回复
热议问题