如何在android中制作Text Shadow?

时间:2016-03-18 05:56:40

标签: android

如何在android中制作阴影文本请帮助我

喜欢这个

enter image description here

2 个答案:

答案 0 :(得分:1)

尝试这种方式为文字提供阴影效果

<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" 
 android:background="@color/White"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <TextView android:textColor="@color/Black"
 android:layout_width="wrap_content"
 android:text="Simple Shadow"
 android:layout_height="wrap_content" 
 android:padding="2dp"
 android:shadowColor="@color/TransparentGrey" 
 android:shadowDx="3"
 android:shadowDy="3" 
 android:shadowRadius="0.01" />
</LinearLayout>

color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <color name="White">#FFF</color>
 <color name="Black">#000</color>
 <color name="Grey">#7F7F7F</color>
 <color name="DarkGrey">#4F4F4F</color>
 <color name="Green">#0F0</color>
 <color name="TransparentGrey">#7F000000</color>
</resources>

gradiant.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 <gradient 
 android:startColor="@color/White" 
 android:endColor="@color/Black" 
 android:angle="0"/>
</shape>

输出

enter image description here

答案 1 :(得分:0)

尝试以下代码

 <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:shadowColor="@color/text_shadow"
    android:shadowDx="3"
    android:shadowDy="3"
    android:shadowRadius="5"
    android:text="Hello Shadow Text"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    android:textStyle="bold" />

并将颜色定义为

  <color name="text_shadow">#58ACFA</color>