Search code examples
androidandroid-activitymaterial-design

Make Title Bar Transparent, Transparent ActionBar - Sample Design Included - Is it possible to have such a material design page


I am looking to develop a profile screen for my app. I am using AppCompactActivity as I need my app to support in non-lollipop devices as well. I need to make the title bar transparent only for this particular activity screen in the app.I also want the actionbar to be transparent.

Picture - Material Design Sample Profile Page with Transparent Title and Action Bar

Please see the sample picture above that I got my MaterialDesign site and it will be great someone can get me the code for developing a page like this. Really appreciate the help.


Solution

  • If you are using AppCompatActivity then you can directly do the following in your main/parent activity.

    int FEATURE_ACTION_BAR_OVERLAY : Flag for requesting an Action Bar that overlays window content.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        setContentView(yourview)
    }
    

    And make sure you do not set any background for the action bar.
    Using supportRequestWindowFeature is a convenience for calling getWindow().requestFeature().