2

Here is the problem, I am using toolbar and I am making it's background color white (or grey, doesn't make difference).

Toolbar code:

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:theme="@style/AppTheme"
android:background="?attr/colorPrimaryDark">

Style.xml code:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">#F5F5F5</item>
    <item name="colorPrimaryDark">#000</item>
    <item name="colorAccent">#ffe162ff</item>
</style>

So I read from here that in Lollipop "colorPrimaryDark" must change status bar color, but it doesn't work. I need to change it, bcs status bar text by default is white and with white background it became unreadable. So what I am doing wrong or I don't understand something? At the moment I use <item name="android:statusBarColor">#000</item> to fix my issue, but it is not cool in my opinion.

So in general, I want toolbar with white background color and readable status bar (i.e. or white background and black text, I also read that it is hard to change status bar text color, that means I can only use dark background?? Or black status bar + white default text)

Community
  • 1
  • 1
Panich Maxim
  • 1,105
  • 1
  • 15
  • 34

1 Answers1

0

What happens is that when you set a colorPrimaryDark to a white color (or almost it) the app automatically change the color to black, try to use a darker colorPrimaryDark and it should work without additional code. And it is not possible to change the text color, sorry about that.

Geraldo Neto
  • 3,670
  • 1
  • 30
  • 33
  • Maybe I don't get it, but problem is that when I set colorPrimary = white and colorPrimaryDark = black it doesn't work. Am I understand right, that "colorPrimary" item for toolbar color and "colorPrimaryDark" for status bar color? – Panich Maxim Aug 26 '15 at 16:04
  • Yes, but remendar that you have to use the android material design support library. – Geraldo Neto Aug 26 '15 at 16:10
  • `colorPrimaryDark` should only be a few shades darker than `colorPrimary`. It should never be the complete opposite like in your case with black/white. Go to https://www.materialpalette.com/ and pick a design you like, you can download the finished style.xml at the bottom on the right. – Xaver Kapeller Aug 26 '15 at 16:12