Can't transparent navigation bar and status bar in android - android

I am trying to transparent navigation bar and status bar on Android 13 and below version. But getting different result.
Here what suggested in latest android dev event:
themes.xml
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:navigationBarColor">#android:color/transparent</item>
MainActivity.kt
WindowCompat.setDecorFitsSystemWindows(window, false)
But I am getting result like this in Android 13 and Android 8 version:
Am I missing something? Thank you.

Well, this is an intended behavior. The BottomNavigationView is respecting the bottom navigation bar space, and the bottom navigation bar has a transparent background, it's just that the root layout has a white background.
You can either:
Make the app full screen, so the bottom of the BottomNavigationView neglects the windows insets calculated by bottom navigation bar size, or...
You can change the color of the navigation bar to match the color of the BottomNavigationView so it can look like one view

Related

In Android How To Make Translucent Status Bar With Black Background Navigation Button

Guys I want to have translucent status bar with black background navigation buttons. Just like Netflix App as shown in picture. I tried really hard to find any way but I failed to achieve this. Any Idea?
Add in styles.xml in Base Application style
Change status bar color : <item name="android:statusBarColor">#color/blackColor</item>
For Translucent status bar : <item name="android:windowTranslucentStatus">true</item>
For navigation bar color : <item name="android:navigationBarColor">#color/blackColor</item>
in layout file use : android:fitsSystemWindows="true" in root layout.

Translucent navigation bar

I want to have the content of my layout being displayed under the navigation bar (also called translucent navigation bar). After reading on the internet, it says all you have to do is add this 2 items to style applied to the activity:
<item name="android:navigationBarColor">#android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
The result is, that the navigation bar is light gray and not transparent. How do all the people solve this ?
Problem was the attribute
android:fitsSystemWindows="true"
in the root view of my layout (in this time CoordinatorLayout). This attribute prevents the content of the layout to draw behind the status and navigation bar.

transparent statusbar navigationdrawer after setstatusbarcolor

I'm try to developing an app with a navigation drawer from a template found on github.
In style.xml i have:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#ff0000</item>
<item name="colorPrimaryDark">#0000ff</item>
and the status bar in navigation drawer is ok.
When i click the button it runs this command:
getWindow().setStatusBarColor(Color.GREEN);
Now the status bar color in navigation drawer is no more translucent
How restore status bar color to translucent?
The difference is that the xml defined colors colorPrimary and colorPrimaryDark are not really used to directly set the status bar color.
Actually the statusbar is completely transparent all the time and only the underlaying View is colored. Thats why it can have another color on the left than on the right side (have a look at your second screenshot). If you now call getWindow().setStatusBarColor(..) you indeed color the statusbar directly and over-draw the color of both Views. So it needs to stay transparent!
What you really want to do, is changing the color of the View underlaying the status bar, which is done with the ScrimInsetsFrameLayout class.
Have a look at this question and this class from the library you provided
There you should find all the necessary information to change only the color of the area you want to.
In case you really just want to reset the color:
getWindow().setStatusBarColor(Color.TRANSPARENT);

Android KitKat : All my app content appears behind the ActionBar and StatusBar after changing StatusBar color

I've created a separate xml style file targeting KitKat and I've managed to change the color of the status bar. The only side-effect as seen on the picture, all the content is now moved up beneath the status bar. My question is how can I change the color of the status bar without overlaying this or how can I know the exact top margin I need to put on my content so its starts after the ActionBar and not beneath. Of course I need this to behave as expected on all screen sizes and densities. Thank you
values-v19/styles.xml
<style name="ThemeSelector" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
You should add the following to the top of the view(s)
android:paddingTop="?android:attr/actionBarSize"
If you're using the Support Library for the action bar, you need to remove the android: prefix
android:paddingTop="?attr/actionBarSize"
By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.
EDITED
You can add
android:fitsSystemWindows="true"
in your XML File
Remove from your layout
android:fitsSystemWindows="true"

action bar takes up entire screen

I am using Action Bar Sherlock for compatibility with earlier versions of Android. My objective is to not display the app title in the action bar, but to show a logo on the left and a couple of action buttons on the right. In my styles, I am using these options for the action bar:
<style name="MyActionBarStyle" parent="Sherlock.__Widget.ActionBar">
<item name="background">#drawable/toolbar</item>
<item name="displayOptions">showHome|useLogo</item>
<item name="android:background">#drawable/toolbar</item>
<item name="android:displayOptions">showHome|useLogo</item>
</style>
Everything works as hoped for on Android 2.3. On my Android 4.0.4 test phone, however, the action bar takes up the entire screen, with the app logo on the left, the action buttons on the right, but these are all centered vertically on the screen instead of residing at the top. The gradient for the toolbar, which is actually a very small pic dimensionally, occupies the entire screen (besides the status bar). The rest of the activity below the action bar is not visible.
If I remove showHome from the displayOptions above, the action bar no longer takes up the whole screen. But my logo is now gone. What do I need to do to get this working properly for Android 4?
Thanks in advance for any help.
I determined that this issue is not a problem with ActionBarSherlock, just with Android 4 in general. There seems to be a combination of options that causes this behavior to happen. I couldn't find a satisfactory solution with styles but was able to get the desired behavior in code.

Categories

Resources