Showing posts with label material design. Show all posts
Showing posts with label material design. Show all posts

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

Thursday, July 28, 2016

Apply Material Theme to Activity


This video show how to apply Android provided Material Theme to your Activity.


- Edit values/styles.xml to add a new style inherits from Android provided Material Theme: android:Theme.Material, android:Theme.Material.Light or android:Theme.Material.Light.DarkActionBar.

- Edit AndroidManifest.xml to use the new style.

- You have to change your MainActivity extends Activity. Otherwise the following error will happen:
You need to use a Theme.AppCompat theme (or descendant) with this activity.

The video also show how it display on Multi-Window Mode.


Next:
- Customize theme's colors

Friday, July 8, 2016

elevation effect of overlapped view


This example show how elevation effect of overlapped view.


package com.blogspot.android_er.androidzelevation;

import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

SeekBar seekBarZ1, seekBarZ2;
ImageView image1;
TextView text2;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

seekBarZ1 = (SeekBar)findViewById(R.id.z1);
seekBarZ2 = (SeekBar)findViewById(R.id.z2);
image1 = (ImageView)findViewById(R.id.image1);
text2 = (TextView)findViewById(R.id.text2);

seekBarZ1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
image1.setZ(i);
}
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});

seekBarZ2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
text2.setZ(i);
text2.setText("elevation: " + String.valueOf(i) + "px");
}
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
}
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidzelevation.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>

<SeekBar
android:id="@+id/z1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="10"
android:max="50"/>
<SeekBar
android:id="@+id/z2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="5"
android:max="50"/>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image1"
android:layout_width="200dp"
android:layout_height="200dp"
android:elevation="10px"
android:background="#90F0F0F0"
android:src="@mipmap/ic_launcher"/>
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="5px"
android:textSize="40dp"
android:background="#90F0F0F0"
android:text="elevation: 5px"/>
</FrameLayout>

</LinearLayout>


Tuesday, July 5, 2016

Change elevation at run-time, by calling setZ()

This example show how to change elevation of ImageView programmatically, by calling setZ().


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidzelevation.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>

<SeekBar
android:id="@+id/z"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="20"
android:max="100"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="20dp"
android:background="@android:color/background_dark"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>

</LinearLayout>



package com.blogspot.android_er.androidzelevation;

import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.SeekBar;

public class MainActivity extends AppCompatActivity {

SeekBar seekBarZ;
ImageView image;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

seekBarZ = (SeekBar)findViewById(R.id.z);
image = (ImageView)findViewById(R.id.image);

seekBarZ.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
image.setZ(i);
}
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
});
}
}


more:
elevation effect of overlapped view

Example of applying android:elevation on ImageView

Example to apply android:elevation on ImageView.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidzelevation.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:elevation="20dp"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="20dp"
android:background="@android:color/background_dark"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="20dp"
android:background="#FF0000"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>

</LinearLayout>


Running on ASUS Zenfone 2 running Android 5.0


How it shown on Emulator running Android API 23 and API 19, and also Android Studio Design View:


Tuesday, June 14, 2016

BottomSheetDialog example


The former post show a example of "Implement BottomSheet of Android Design Support Library". This post show a BottomSheetDialog example.


To use Design Support Library in your app, you have to "Add Android Design Support Library to Android Studio Project", currently version 'com.android.support:design:23.4.0'.


Create a file layout/bottomsheetdialog_layout.xml, to define the layout of the BottomSheetDialog.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Bottom Sheet Dialog Example"
android:textSize="26dp"
android:textStyle="bold"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"/>

</LinearLayout>
</LinearLayout>

layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidbottomsheetdialog.MainActivity">

<LinearLayout
android:id="@+id/backgroundlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold" />
<TextView
android:id="@+id/textSDK"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/prompt1"
android:textSize="28dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/prompt2"
android:textSize="28dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>


MainActivity.java
package com.blogspot.android_er.androidbottomsheetdialog;

import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

LinearLayout backgroundLayout;
View bottomSheetView;
TextView textPrompt1, textPrompt2;
TextView textSDK;

BottomSheetDialog bottomSheetDialog;
BottomSheetBehavior bottomSheetBehavior;

int sdk_int = Build.VERSION.SDK_INT;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

textSDK = (TextView)findViewById(R.id.textSDK);
textSDK.setText("Running SDK_INT: " + sdk_int);

textPrompt1 = (TextView)findViewById(R.id.prompt1);
textPrompt2 = (TextView)findViewById(R.id.prompt2);
backgroundLayout = (LinearLayout)findViewById(R.id.backgroundlayout);

bottomSheetView = getLayoutInflater().inflate(R.layout.bottomsheetdialog_layout, null);
bottomSheetDialog = new BottomSheetDialog(MainActivity.this);
bottomSheetDialog.setContentView(bottomSheetView);
bottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetView.getParent());
bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);

bottomSheetDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
textPrompt1.setText("OnShow");
}
});

bottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
textPrompt1.setText("OnDismiss");
}
});

backgroundLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
bottomSheetDialog.show();
}
});

}

BottomSheetBehavior.BottomSheetCallback bottomSheetCallback =
new BottomSheetBehavior.BottomSheetCallback(){
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch (newState){
case BottomSheetBehavior.STATE_COLLAPSED:
textPrompt2.setText("COLLAPSED");
break;
case BottomSheetBehavior.STATE_DRAGGING:
textPrompt2.setText("DRAGGING");
break;
case BottomSheetBehavior.STATE_EXPANDED:
textPrompt2.setText("EXPANDED");
break;
case BottomSheetBehavior.STATE_HIDDEN:
textPrompt2.setText("HIDDEN");
bottomSheetDialog.dismiss();
break;
case BottomSheetBehavior.STATE_SETTLING:
textPrompt2.setText("SETTLING");
break;
default:
textPrompt2.setText("unknown...");
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {

}
};
}




~ More example of using Android Design Support Library, Snackbar, FloatingActionButton.

Wednesday, June 8, 2016

Implement BottomSheet of Android Design Support Library

BottomSheet run on API 19

BottomSheet run on API 23
With the help from the Android Design Support Library, you can implement a number of important material design components to all developers and to all Android 2.1 or higher devices.

This example show how to implement Bottom Sheets with help of Android Design Support Library.




To use Design Support Library in your app, you have to "Add Android Design Support Library to Android Studio Project", currently version 'com.android.support:design:23.4.0'.


activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.blogspot.android_er.androidbottomsheet.MainActivity">

<LinearLayout
android:id="@+id/backgroundlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold" />
<TextView
android:id="@+id/textSDK"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/prompt"
android:textSize="28dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

<android.support.v4.widget.NestedScrollView
android:id="@+id/bottomsheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"
android:background="@android:color/darker_gray"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Bottom Sheet Example"
android:textSize="26dp"
android:textStyle="bold"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>

</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>


MainActivity.java
package com.blogspot.android_er.androidbottomsheet;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

LinearLayout backgroundLayout;
View bottomSheet;
private BottomSheetBehavior bottomSheetBehavior;
TextView textPrompt;
TextView textSDK;

/*
Build.VERSION.SDK_INT:
The user-visible SDK version of the framework;
its possible values are defined in Build.VERSION_CODES.
https://developer.android.com/reference/android/os/Build.VERSION_CODES.html
*/
int sdk_int = Build.VERSION.SDK_INT;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

textSDK = (TextView)findViewById(R.id.textSDK);
textSDK.setText("Running SDK_INT: " + sdk_int);

textPrompt = (TextView)findViewById(R.id.prompt);
backgroundLayout = (LinearLayout)findViewById(R.id.backgroundlayout);

bottomSheet = findViewById(R.id.bottomsheet);
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);

backgroundLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (bottomSheetBehavior.getState()){
case BottomSheetBehavior.STATE_COLLAPSED:
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
break;
case BottomSheetBehavior.STATE_EXPANDED:
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
break;
}
}
});

}

BottomSheetBehavior.BottomSheetCallback bottomSheetCallback =
new BottomSheetBehavior.BottomSheetCallback(){
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch (newState){
case BottomSheetBehavior.STATE_COLLAPSED:
textPrompt.setText("COLLAPSED");
break;
case BottomSheetBehavior.STATE_DRAGGING:
textPrompt.setText("DRAGGING");
break;
case BottomSheetBehavior.STATE_EXPANDED:
textPrompt.setText("EXPANDED");
break;
case BottomSheetBehavior.STATE_HIDDEN:
textPrompt.setText("HIDDEN");
break;
case BottomSheetBehavior.STATE_SETTLING:
textPrompt.setText("SETTLING");
break;
default:
textPrompt.setText("unknown...");
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {

}
};
}


(reference: http://android-developers.blogspot.hk/2016/02/android-support-library-232.html)

Next:
Sets the height of collapsed bottom sheet, by calling setPeekHeight() method
BottomSheetDialog example

~ More example of using Android Design Support Library, Snackbar, FloatingActionButton.

Thursday, December 18, 2014

Using Toolbar in android in LollyPop and Pre-Lollypop Devices - Part 2



1) toolbar.xml


<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/md_blue_500_primary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
</android.support.v7.widget.Toolbar>


2) activity_main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />

<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter Name"
android:inputType="textPersonName"
android:textColor="@color/md_black">
<requestFocus />
</EditText>

</LinearLayout>


3)  MainActivity.java


package com.pratap.materialdesign;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends AppCompatActivity {

private Toolbar toolbar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

toolbar = (Toolbar) findViewById(R.id.toolbar);

toolbar.setTitle("Material Design");
//toolbar.setSubtitle("AppCompat");
//toolbar.setTitleTextColor(Color.RED);

setSupportActionBar(toolbar);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}




4) values/styles.xml

<resources>
    <!-- Base application theme using AppCompatv21 Library -->
<style name="AppBaseTheme" parent="Theme.AppCompat">

<!-- your app branding color for the app bar -->
<item name="colorPrimary">@color/md_blue_500_primary</item>

<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/md_blue_700</item>

<!-- Change the Background color of the window in the activity -->
<item name="android:windowBackground">@color/md_white</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorAccent">@color/md_red_200</item>

<!-- Chnaging the toolbar text color -->
<!-- <item name="android:textColorPrimary">@color/md_red_500_primary</item> -->

<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme"></style>

</resources>

5) values-21/styles.xml

<resources>

<style name="AppTheme" parent="AppBaseTheme">
<!-- API 21 theme customizations can go here. -->

<item name="android:navigationBarColor">@color/md_cyan_500_primary</item>
</style>

</resources>


6)  AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pratap.materialdesign"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />

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

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

</manifest>



7) Build and Run the Code


ScreenShot: