Thursday, December 3, 2015

Change Status bar color for your application

 




Note:- this feature is supported on api level 19 or 21 and above api level.

Step 1:- First make foloder in res and give name values-v19 or values-v21 and create style.xml in this folder and put following code is style.xml.

<style name="MyMaterialThemeWithMargin" parent="@style/Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimaryDark">#0973AE</item>
        <item name="android:navigationMode">tabMode</item>
        <item name="android:layout_marginTop">30dp</item>
</style>

Hear "colorPrimaryDark" is set status bar color.
Step 2:- Now this style is set in Your layout by theme attributes like following code and Run Your Project.

 <RelativeLayout
        android:id="@+id/ll_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:theme="@style/MyMaterialThemeWithMargin"
        android:background="@color/homeTitleColor">
</RelativeLayout 




No comments:

Post a Comment