Status bar color of main activity changes but other activities status bar color remains same


Status bar color of main activity changes but other activities status bar color remains same



How do i change my status bar color to black for all activities as this code only changes status bar color of main activity to black and color of status bar in other activities remain grey.


<style name="CustomToolbarStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">-4dp</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">#000000</item>
<item name="android:textColorSecondary">@color/white</item>
</style>





mainfests: <application android:theme="@style/Theme.AppCompat.Light.NoActionBar">
– Owais Yosuf
Jul 2 at 19:05





how and where did you apply this theme?
– Mangal
Jul 2 at 19:52





Did you get what you were looking for?
– Mangal
Jul 3 at 7:18




2 Answers
2



By default the theme which is set in Manifest's tag is used to set theme of an activity declared which not having any theme.



You should apply your mentioned theme in Application's theme attribute in Manifest.


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/CustomToolbarStyle">
.....
</application>



And this theme will be overriden by the theme which you set in Activity tag's theme attribute in Manifest or theme which is set from Activity's layout, again by theme attribute.



You have to define this theme for other activities too in your manifest


<activity
android:name=".YourActivityName"
android:theme="@style/CustomToolbarStyle"/>



You can set this theme for all the activities in which you want black status bar color
the color responsible for status color is colorPrimaryDark defined in your colors.XML


colorPrimaryDark






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages