shark
shark

Reputation: 1015

Apply material design on Android 4.4 KitKat

I've tried my best to apply Material Design for Android SDK lower than 21, but I failed.
I downloaded appcompat-v7, added it to my maven file as:

<dependency>
    <groupId>com.android.support</groupId>
    <artifactId>appcompat-v7</artifactId>
    <version>21.0.0</version>
    <type>apklib</type>
</dependency>
<dependency>
    <groupId>com.android.support</groupId>
    <artifactId>appcompat-v7</artifactId>
    <version>21.0.0</version>
    <type>jar</type>
</dependency>

But Material Design is still unavailable. Is there any tutorial on how to do it? I want to make an application similar to Gmail version 5, but the SDK forces me to change API level to 21.

I'm only interested in layout. I do not want to use any other SDK 21 features. I'm using IntelliJ Idea and Maven. My target API level is 17

Upvotes: 1

Views: 8572

Answers (2)

Inoy
Inoy

Reputation: 1075

May be, you could use this

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?

.

Have I answered your question?)

Upvotes: 3

equerambug
equerambug

Reputation: 47

You have to create 2 different styles.xml files with the same name that you will put in different folders.

The first, will go here:

res/styles.xml

and will look NOT have a reference to the Material theme (use the Holo theme):

so would have something like this:

<style name="AppTheme" parent="android:Theme.Holo.Light"></style>

The second will go here:

res/values-v21/styles.xml

and WILL contain the reference to the new Material theme, and would have:

<style name="AppTheme" parent="android:Theme.Material.Light"></style>

The Android framework will automatically use the correct one depending on which API the device supports (so on API 21 devices it will use Material, and on all other devices, it will use whatever else you define).

refe (Using Android L Material Design on KitKat)

Upvotes: 2

Related Questions