【发布时间】:2015-01-11 11:02:15
【问题描述】:
您好,我正在开发 android 应用程序,我正在尝试实现新的材料设计功能。我试图应用海拔属性,但它不适合我。我尝试了以下方式。
<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>
【问题讨论】:
-
你更新最新的API了吗??
-
尝试给一些不透明的背景颜色或图像。
标签: android material-design android-elevation