user3748230
user3748230

Reputation:

Material Design theme in android

I am learn about how to apply theme in app.

<style name="Theme.BaseApp" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="android:colorPrimary">@color/colorPrimary</item>
    </style>

When we use android:colorPrimary line.

Please help me.

Upvotes: 0

Views: 1133

Answers (2)

Inoy
Inoy

Reputation: 1075

Here is complex answer for you

Material Design from Android 2.2 (API 8) to present 5.0 (API 21)

Here what you need:

  1. Toolbar
  2. Material Design Library for widgets (buttons, checkboxes, etc)

1. Toolbar

Just get the idea and you ready to go.

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimaryDark"/>

Setup guide: http://antonioleiva.com/material-design-everywhere/

Source with example: https://github.com/antoniolg/MaterialEverywhere

To make Toolbar work lower API 11 use Theme.AppCompat.Light.NoActionBar (instead windowActionBar set to false)

<style name="NoActionBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
     ...
</style>

2. Material Design Library

Here is Material Design Library for pretty buttons, etc.. Currently it's heavily developed.

Guide, code, example - https://github.com/navasmdc/MaterialDesignLibrary

Guide how to add library to Android Studio 1.0 - How do I import material design library to Android Studio?

.

Hope it helps :)

Upvotes: 0

Chris K.
Chris K.

Reputation: 987

I dont really know what are you asking for. You set @color/colorPrimary in a separeate colors.xml file. Then after you assign your color to <item name="android:colorPrimaryDark">@color/colorPrimary</item> it will be automatically used for some things in the theme like notification bar etc

Example:

styles.xml

<style name="AppTheme" parent="android:Theme.Material.Light">
    <item name="android:colorPrimary">@color/primary</item>
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <item name="android:colorAccent">@color/accent</item>
</style>

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="primary">#2196F3</color>
    <color name="primary_dark">#0D47A1</color>
    <color name="accent">#FF9800</color>
</resources>

You can then use those colors to keep consistent color palette over your app.

Upvotes: 1

Related Questions