Hi I am developing android application in which I am trying to implement new material design features. I tried to apply elevation property but it is not working for me. I tried it in following way.
<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 is not showing any shadow for that image. Am I doing anything wrong? Need some help. Thank you.
I tried in this way as well 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>
On Lollipop it works setting elevation. For pre-Lollipop, you need to implement shadows by yourself. Support-v4 has ViewCompat.setElevation(view, value) method for by if you check the sources there is no implementation. (at least, at the time of writing).