2

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.

sreeragnk
  • 53
  • 2
  • 10

3 Answers3

2

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().

Shadow Droid
  • 1,696
  • 1
  • 12
  • 26
  • I have tried this and it is a working solution for making ActionBar transparent. However, 'AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR_OVERLAY' is the updated solution. I am still not able to make the status bar transparent. Is there any similar method, that you applied to actionbar, available for title bar as well? Please refer the image. – sreeragnk Nov 01 '15 at 05:34
  • @sreeragnk have you tried what is suggested here http://stackoverflow.com/questions/27856603/lollipop-draw-behind-statusbar-with-its-color-set-to-transparent – Shadow Droid Nov 01 '15 at 11:12
  • The problem is I am using minSdkVersion 16. – sreeragnk Nov 01 '15 at 11:47
0

You can style for this

    <style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
       <item name="background">@android:color/transparent</item>
    </style>

Or if programmatically you can use

    actionbar.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT))

Hope it helps. I prefer style :)

Amit Kumar
  • 391
  • 3
  • 10
0

Another way is to use hex color:

 actionbar.setBackgroundDrawable(new ColorDrawable("#00343434"))

#00343434 first 2 number describes its transparency.

  • 00 --> %100 transparent
  • ..
  • ..
  • FF --> no transparent

look for detail about transparent codes;

necip
  • 333
  • 4
  • 11