Example Of Applying Android:Elevation On Imageview

Posted on

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="https://rootandroid.org//"         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 ii running Android 5.0

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