0

I'm trying to make Navigation Bar transparent, but keep Action Bar as it is.
Following code makes both transparent:

Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

Please suggest how to make transparent Navigation Bar only.

enter image description here

surlac
  • 2,961
  • 2
  • 22
  • 31

1 Answers1

2

Edit : After reading the source, i understood the problem. The OP has not declared the styles in a proper way ie., the custom themes were not extending the default themes. Hence it made the actionbar to be transparent.

Previous Answer :

If you are targeting kitkat and above, add the following to your style. (Else do it in values-v19 styles file)

<item name="android:windowTranslucentNavigation">true</item>

this will make the navigation bar translucent.

Or you can do it programmatically,

Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
Riyaz Ahamed
  • 802
  • 8
  • 14
  • Didn't help, the Action Bar still transparent. The app is very simple, Activity with white background. If I run without FLAG_TRANSLUCENT_NAVIGATION - Action Bar and Nav Bar are black. With this flag - both white. – surlac Jul 30 '15 at 19:02
  • are you sure that you are not doing anything else with actionbar? – Riyaz Ahamed Jul 30 '15 at 19:05
  • I'm not doing anything with actionbar. setFlags() removed.Here are the [project files](http://www.mediafire.com/download/poubjb83k1igodi/nav_bar.zip). Running on 4.4.4. – surlac Jul 30 '15 at 19:13
  • Your styles must extend a parent theme. For eg; – Riyaz Ahamed Jul 30 '15 at 19:20
  • Yes! I set parent="@android:style/Theme.Holo.Light.DarkActionBar" as per your suggestion, and it worked perfectly! Please update your answer (since the solution here is "parent", doesn't matter how you set windowTranslucentNavigation) and I'll mark it as accepted. Thanks! – surlac Jul 30 '15 at 20:29