你好,我正在开发一款Android应用程序,尝试实现新的Material Design功能。我试图应用高程属性,但它对我没有起作用。我是以下面的方式尝试的:
<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>
那张图片没有显示任何的阴影,我做错了什么吗?需要帮助,谢谢。
我也试过这种方法,但输出结果还是没有改变。
<?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>