Android TextView下的阴影

时间:2014-03-06 08:56:41

标签: android textview shadow android-drawable

我一直在尝试在TextView下添加阴影效果,但出于某种原因,它无法正常工作!布局XML如下所示。有人可以帮忙找出原因吗?

<TextView
    android:id="@+id/textView1"
    android:text="Hello World!"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="@drawable/myshape"
    android:shadowColor="#ff0000"  
    android:shadowRadius="3"  
    android:shadowDx="2"  
    android:shadowDy="2"
    android:gravity="center"
    android:textAppearance="?android:attr/textAppearanceMedium" />

myShape Drawable:

    <?xml version="1.0" encoding="utf-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" >
    android:shape=["rectangle"] >
  <stroke
    android:width="2dp"
    android:color="#FFFFFFFF" />
  <gradient
    android:endColor="#DDBBBBBB"
    android:startColor="#DD777777"
    android:angle="90" />
  <corners
    android:bottomRightRadius="15dp"
    android:bottomLeftRadius="15dp"
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp" />

</shape>

The layout generated so far:

0 个答案:

没有答案