The Elevation property does not work.

Hi, I am developing an Android application in which I am trying to implement new material design features. I tried to apply the height property, but it does not work for me. I tried it as follows.
<RelativeLayout 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:background="#FFFFFF"
tools:context="com.example.androidmaterialsamples.MainActivity" >
<ImageView 
    android:id="@+id/sampleImage"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/ic_launcher"
    android:layout_centerInParent="true"
    android:elevation="10dp"/>
 </RelativeLayout>

It does not show shadows for this image. Am I doing something wrong? Help is needed. Thank.

I tried in the same way, but still no change in output.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
<solid android:color="#0073ff" />
<corners android:radius="16dp" />
</shape>

<RelativeLayout 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:background="#FFFFFF"
tools:context="com.example.androidmaterialsamples.MainActivity" >
<TextView 
    android:id="@+id/sampleImage"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="my name is nilesh"
    android:padding="10dp"
    android:textSize="20sp"
    android:layout_centerInParent="true"
    android:elevation="12dp"
    android:background="@drawable/background"/>
</RelativeLayout>
+4
source share
2 answers

Lollipop . pre-Lollipop . Support-v4 ViewCompat.setElevation(view, value) , , . ( , ).

0

, android: src, android: background .

<ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:elevation="10dp"
        android:background="@drawable/ic_launcher"/>
0

All Articles