Android Lollipop transparent statusbar - android

My problem is easy but I need some help
I have a MainActivity, several Fragments and NavigationDrawer. I also use a Appcompat v7
NavigationDrawer is shown behind the statusbar for what I use ScrimInsetsLayout.
In styles I have colorPrimary and colorPrimaryDark(parent is Theme.Appcompat)
In main activity I use setStatusBarColor(Color.TRANSPARENT) to show Drawer in statusbar. So now I have colorPrimaryDark statusbar color and NavigationDrawer in statusbar
Now I created a new Fragment and I need to disable colorPrimaryDark color and make statusbar real transparent
As I said before, setting color to transparent makes it colorPrimaryDark with drawer shown
Setting it to any other color "hides" drawer.
Thanks
Screenshots:

The transparent translucent status bar is available from API 19, create a new values-v19 folder and a styles.xml inside it then update your BaseAppTheme like this:
<!-- Base application theme for v19. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
But, this would make your UI use the space behind StatusBar, so I would suggest adding an extra TOP padding, of 25dp (researched and found every API uses 25dp as StatusBar height even in landscape mode), for devices > API19

Related

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);

How to tint AppCompat r22.1 action bar overflow icon?

I know it's possible to replace the icon by setting a custom actionOverflowButtonStyle as described here. However, that style only allows setting a different drawable and or/background.
Instead, I would like to use the standard icon provided by AppCompat, just tinting it with a particular color, just as the drawer icon/back button can be tinted via the color attribute in drawerArrowStyle.
I have tried these methods, which reportedly used to work:
Setting colorControlNormal -- Toolbar icon tinting on Android
Setting textColorPrimary in the theme -- MenuItem tinting on AppCompat Toolbar
Setting a custom actionBarStyle and changing colorControlNormal there.
But as far as I can see none of them work with the latest AppCompat -- the overflow icon keeps its original color (while other widgets, such as TextViews or the text in menu items do change).
Should this be done differently now? I am not using a custom Toolbar view, just the default AppCompat-provided, ActionBar-like one.
How to reproduce:
Create a default Android Studio project, with minimum SDK version = 9.
This automatically includes a blank activity and a menu resource with a single menu item, "Settings", with app:showAsAction="never" which means it will be displayed in the overflow menu.
Finally, customize the styles.xml file. For example:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#008888</item>
<item name="colorControlNormal">#ff0000</item>
<item name="android:textColorPrimary">#ff0000</item>
</style>
</resources>
You'll notice that neither property affects the overflow menu icon color. Tested in a Nexus 5 with Android 5.1.1.
If you trace the Theme.AppCompat.Light.DarkActionBar theme, you see that it sets:
<item name="actionBarTheme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
Which in turn inherits from Base.ThemeOverlay.AppCompat.Dark, which sets:
<item name="android:textColorPrimary">#color/abc_primary_text_material_dark</item>
Which essentially equals white:
<color name="primary_text_default_material_dark">#ffffffff</color>
If you just inherit from Base.Theme.AppCompat.Light, you won't run into this issue since it doesn't set the actionBarTheme. You can easily customize the action bar using the material properties anyway.

Android AppCompat 22.1.1 default text color and ActionMode style

I am updating my application to use the version 22.1.1 of the Android Support Library. My application theme inherits from Theme.AppCompat.Light.DarkActionBar.
It works fine, except that all texts are white if the TextView style is set to one of the predefined style. So I end up with white texts on light background (default background color). With version 22.0.0, I had no issue.
I tried the follow in my theme, but it does not seem to work:
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
<item name="android:textColorPrimaryInverse">#color/black</item>
Moreover, the ActionMode now has a black background instead of white, as it used to be with 22.0.0.
Any idea on how to change this?
I was using the theme attribute in my theme to set the Toolbar theme. That's a mistake. The Toolbar theme has to be defined on the Toolbar tag directly.
For the ActionMode background color, it looks like I was taking profit of a bug without knowing it.

Remove pressed effect on action bar home icon

First, a few words about the app : minimum level is 16, I use a DrawerLayout (with the indicator) and have changed the background of my ActionBar.
When clicking on the home button to open the drawer, there is a blue pressed effect on both the image and the drawer indicator, that I'd like to remove. I tried setting selectableItemBackground in the styles to transparent, nearly everywhere I could think of, but that doesn't seem to change anything. Do anyone have a solution ?
Here is the image of this effect I'd like to remove :
Here is the styles.xml part for the ActionBar I'm using :
<style name="ActionBar.Solid.Bnp" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/action_bar_green</item>
<item name="android:titleTextStyle">#style/ActionBar.Title</item>
<item name="android:actionBarItemBackground">#null</item>
</style>
and finally the drawable used for background.
selectableItemBackground is close, but you need to use the actionBarItemBackground attribute instead.
For instance:
<style name="Your.Theme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#null</item>
</style>
You should keep in mind that the system uses this attribute in the ActivityChooserView too, which is what the ShareActionProvider returns in ActionProvider.onCreateActionView.
To highlight all this, here are the results when you use #android:color/holo_red_light instead:

HoloEveryWhere not changing ActionBarColor on ICS + - Custom theme

I am using HoloEveryWhere Library with Holo.Theme.Sherlock.Light as the parent theme. I am also using splitActionBarWhenNarrow and so the top ActionBar and bottom ActionBar will be of Light colors. I would like to have dark color in top ActionBar, so I have changed it programmatically and it works fine.
As I have Light theme as parent and dark color in top ActionBar, the homeAsUpIndcator will be of dark color which is not visible in a dark top ActionBar.
Thus I have created a custom theme to make the homeAsUpIndcator a light one. I have succeeded in what I need using this theme :
`
<style name="AppTheme" parent="#style/Holo.Theme.Sherlock.Light">
<item name="android:homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
<item name="homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
</style>
`
This is working perfectly in Android 2.2 Emulator but not in ICS+ I am getting the dark bottom ActionBar and ActionPopupMenus :(
Actually I did not specify any Dark theme anywhere!
Am I missing any attributes for the custom theme ?
I suspect that you have a values-v11 folder where you also have your theme declared('AppTheme'). You can remove the style(if you don't plan to do something else with it)

Categories

Resources