CollapsingToolbarLayout: statusBarScrim for expanded state? - android

I'd like to use a CollapsingToolbarLayout to achieve an effect as in the following image:
To accomplish this, I first tried to set the status bar background color to a 30% opacity black in my theme. This works fine for the expanded state and achieves the intended effect.
However, I'd also like to use #color/primaryColorDark for the status bar as background when the CollapsingToolbarLayout is collapsed. So I set app:statusBarScrim to #color/primaryColorDark, but because the status bar background is set to semi-transparent black in the theme, the color is darker than #color/primaryColorDark.
How do I set a status bar scrim that is used when the CollapsingToolbarLayout is expanded? CollapsingToolbarLayout has app:statusBarScrim for the collapsed state, but there is no such attribute for the expanded state. If I could do this, I can set the status bar to fully transparent and avoid the problem of the overly dark status bar in collapsed state.
Alternatively, is there a way to only set the status bar background to transparent when the CollapsingToolbarLayout is collapsed?

Related

Android Studio make status bar background complete transparent and change icon color

i need to make the status bar transparent, and change the icon color to a darker grey. Because i am using a viewpager and the layout must go below the status bar, i also tried it with
"windowTranslucentStatus=true"
But with it i cant change the color of status bar and it wasn't transparent, it was a darker grey and light transparent. And i want to change the color of the status bar in the layout when it is transparent. So i can create on the top of my layout, a view that has a height of 25dp and can change there the color, and when i am swiping, the color on the status bar should swiping too.
If im not doing this it look very terrible.
Thank you
Try this for status bar
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}
Works with ActionBarActivity.

Set color behind transparent status bar

I want to be able to change the color behind a transparent status bar.
I know how to change the status bar color, but then it becomes a solid color and and opening the navigation drawer no longer draws it behind the a translucent status bar.
The cyan color is the primary dark background color. The toolbar has been colored programatically to green, and making darkGreen the primaryDark color is not an option because there are other colors.
(Sort of like the Google+ App, where the Primary/PrimaryDark color seems to be able to change depending on what fragment is selected)
So how can I change the color behind the translucent status bar programatically on runtime, to green?

Extend Toolbar behind Status Bar

I have an application in which I would like to change the color of the Toolbar fairly often.
Right now, I am manually setting the Status Bar color and the Toolbar color (where the status bar color is a darker version of the toolbar color).
Is it possible to instead use
<item name="android:windowTranslucentStatus">true</item> in my style and have my Toolbar extend behind the status bar? That way, I wouldn't have to manually create a dark color and manually set the status bar color in addition to the toolbar color. This would also allow the navigation drawer to show in front of the status bar color and behind the actual status bar (Right now the top of the navigation drawer isn't shown because the status bar is a solid color)
i think what you are looking for is this
android:fitsSystemWindows
Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.
Must be a boolean value, either "true" or "false".
This may also be a reference to a resource (in the form "#[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
This corresponds to the global attribute resource symbol fitsSystemWindows.
Try this to put toolbar behind status bar:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
before setContentView in Activity and add to styles windowTranslucentStatus, it makes Top of a Drawer visible

Material: Navigation bar elevation or shadow

Setting the navigation bar color to something other than black only plays well with material design if you set it to transparent (or the same color as the window background) and the content is not scrollable.
<item name="android:navigationBarColor">#android:color/transparent</item>
If the navigation bar has another color or if the content is scrollable, the ink just gets cut off when reaching the bar like in the picture:
I would like to set an elevation on the navigation bar so that it casts a shadow and it becomes clear that it's another layer. Is this possible?
According to Google I/O Android talks, all shadows are generated by some light source, which provides shadows under elements, not above them. Then, Navigation Bar should have no visible shadow.
Maybe, the only solution of your problem is to use additional drawable to imitate shadow.

Android 5.0: Recolor status bar icons

In my app, I am animating the status bar color between a dark blue color and white using Window.setStatusBarColor(). The icons in the status bar are initially white, like they should be. However, when I animate the background color to white, the icons stay white, making the contents of the status bar invisible. Is there a way to tell the system to recolor the things in the status bar to black?

Categories

Resources