Android Elevation Example with Tutorial

Android Elevation comes with Google material design this attribute gives us the facility to set relative depth or we can call that, distance between two surfaces along Z-Axis. So here is the complete step by step tutorial for Android Elevation Example with Tutorial.

android-project-download-code-button

Android Elevation Example with Tutorial.

Code for MainActivity.java file.

package com.elevation_android_examples.com;
import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

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

Code for activity_main.xml layout file.

 <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:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.elevation_android_examples.com.MainActivity"
 android:orientation="vertical" >

 <TextView
 android:id="@+id/textView1"
 android:layout_width="fill_parent"
 android:layout_height="120dp"
 android:text="TextView Text"
 android:textAppearance="?android:attr/textAppearanceLarge"
 android:elevation="20dp"
 android:background="#01e0fd"
 android:gravity="center"
 android:layout_marginTop="15dp"
 />
 <TextView
 android:id="@+id/textView2"
 android:layout_width="fill_parent"
 android:layout_height="120dp"
 android:text="TextView Text"
 android:textAppearance="?android:attr/textAppearanceLarge"
 android:elevation="20dp"
 android:background="#01e0fd"
 android:gravity="center"
 android:layout_marginTop="15dp"
 />
 <TextView
 android:id="@+id/textView3"
 android:layout_width="fill_parent"
 android:layout_height="120dp"
 android:text="TextView Text"
 android:textAppearance="?android:attr/textAppearanceLarge"
 android:elevation="20dp"
 android:background="#01e0fd"
 android:gravity="center"
 android:layout_marginTop="15dp"
 />
 

</LinearLayout>

Screenshot :

Android Elevation Example with Tutorial

Click here to download Android Elevation Example with Tutorial project.