我想在最新的Android Lollipop预览版中使用elevation属性.我将targetSdk设置为21,将主题设置为Material.接下来,我将一个背景形状添加到TextView并将高程设置为8dp,但TextView没有显示任何阴影的迹象.这是在运行棒棒糖预览的Nexus7上.还有什么我需要考虑的吗?
这是布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rect"
android:text="hallo world"
android:padding="8dp"
android:elevation="8dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是背景可绘制的:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#7d0073ff" />
<corners android:radius="16dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
这是TextView:
