Monday, August 8, 2016

Customize theme's colors


Last example show how to Apply Material Theme (with default color) to Activity. The video show how to further custom the theme colors.


Edit values/styles.xml to modify style of "AppTheme2", adding various color defination.
<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="AppTheme2" parent="android:Theme.Material">
        <item name="android:colorPrimary">@android:color/holo_orange_light</item>
        <item name="android:colorPrimaryDark">@android:color/holo_orange_dark</item>
        <item name="android:textColorPrimary">@android:color/holo_blue_bright</item>
        <item name="android:windowBackground">@android:color/darker_gray</item>
        <item name="android:navigationBarColor">@android:color/holo_green_dark</item>
    </style>

</resources>


Make sure "@style/AppTheme2" is used in AndroidManifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.blogspot.android_er.androidmultiwindow">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme2">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>


Reference:
Using the Material Theme

No comments: