Show ImageView partly behind transparent ActionBar

前端 未结 4 1106
暖寄归人
暖寄归人 2020-12-02 12:45

The Google Maps application has a transparent ActionBar, through which the map is visible.

\"enter

4条回答
  •  失恋的感觉
    2020-12-02 12:57

    You can also set it at run-time:

    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    

    This will the ActionBar a semi-transparent floating bar.

    Like any requestWindowFeature..., this should be called before adding content.

    After the setContentView, you can then set a background from your Drawable with this:

    getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
    

    Change getActionBar with getSupportActionBar for ActionBarSherlock

    actionbar_bg.xml with the root element of shape:

    
    

    Although I find Tomik's solution great, this will be useful for those one-off cases for a few activities rather than an across the board style.

提交回复
热议问题