1

on my create screen, the nav bar is black instead of this pinky colour I made it to be. I don't really know what's the issue

styles.xml

    <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>


    <style name="CreateTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorAccent">@color/colorCreate</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    </style>

</resources>

manifest code

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app.supermarketaislefinder">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true">

        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".create"
            android:theme="@style/CreateTheme"/>

        <activity android:name=".view" />
        <activity android:name=".settings"></activity>

        <meta-data
            android:name="preloaded_fonts"
            android:resource="@array/preloaded_fonts" />
    </application>

</manifest>

I tried taking android:theme"@style/AppTheme" and putting it under the tag but no difference.

1 Answers1

2

I assume you mean the toolbar (bar at the top of screen) when you say nav bar. By default, the toolbar color is the same as colorPrimary if the toolbar was generated for you. Check that the toolbar has android:background="?attr/colorPrimary" inside of it then change the primary color with your custom color.

<style name="CreateTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorCreate</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>
Tohu
  • 151
  • 2
  • 4
  • 2
    thank you, that worked. I was also wondering how to change the colour of the bar right at the top which shows the time, wifi, signal etc. On my phone , it's just the normal grey colour. –  Jul 21 '18 at 06:32
  • 1
    @crazyCoderN The bar you're referring to is called the status bar. If your minimum SDK is at least 21 then you should be able to use `@color/colorCreate`. Check out [this post.](https://stackoverflow.com/questions/22192291/how-to-change-the-status-bar-color-in-android) – Tohu Jul 21 '18 at 07:10
  • 1
    thanks for that. My phones sdk is 16. Is it possible to make it so you can still run the app on a phone with an sdk less than 21 but it won't show the status bar colour? and you can still run it on a phone with a sdk higher than 21 and it'll show the colour? –  Jul 21 '18 at 21:44
  • 2
    @crazyCoderN I think you can't change the status bar color for SDK lower than 21 so you don't have to worry about it. But I recommend creating a separate `styles.xml` for min SDK >= 21. To do so, create a folder called `values-v21` inside `res` and put a new `styles.xml` inside. By separating the styles, you can use version-specific style features like the `statusBarColor`. – Tohu Jul 22 '18 at 00:35