0

On Android I can set a transparent statusbar with the following style line:

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

I would like to display a text directly under the statusbar with the same background color of the statusbar. My problem is if I set the background color to my primaryColor it is a bit brighter because I haven't added the alpha value of the statusbar to the color.

So how can I get the alpha value of the statusbar from code to add it to my background color?

Cilenco
  • 6,951
  • 17
  • 72
  • 152
  • Did You see [this](http://stackoverflow.com/a/28041425/6950238) question? – Andrii Omelchenko Oct 22 '16 at 21:25
  • Thanks for this answer but it's not what I'm looking for.I would like to display a View below the statusbar (to create an extended effect) with the sane alpha value and do not want to Draw behind it. – Cilenco Oct 23 '16 at 07:50
  • Did You try get screenshot like in [this](http://stackoverflow.com/a/35150398/6950238) question and get alpha value for pixel corresponding to StatusBar like in [that](http://stackoverflow.com/questions/7645607/android-check-alpha-of-pixel)? – Andrii Omelchenko Oct 24 '16 at 16:47

2 Answers2

0

Do you want like this ?

enter image description here

If yes. After Android 5.0. You should set colorPrimaryDark same as colorPrimary. colorPrimaryDark means status bar color. And one important step, if your layout code like this:

   <android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

Delete "AppBarLayout". Change to :

  <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />
SawDouma
  • 11
  • 4
0

On Activity, try get this window.statusBarColor