Saturday, May 5, 2012

Place shadow behind text using XML


Place shadow behind text using XML

We can define XML Attributes to place a shadow of the specified color behind the text.
  • android:shadowColor - Place a shadow of the specified color behind the text.
  • android:shadowDx - Horizontal offset of the shadow.
  • android:shadowDy - Vertical offset of the shadow.
  • android:shadowRadius - Radius of the shadow.


Place shadow behind text

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:textSize="20dp"
    android:shadowColor="#FFFFFF"
    android:shadowRadius="5"
    android:shadowDx="10"
    android:shadowDy="10"
    />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:shadowColor="#000000"
    android:shadowRadius="5"
    android:shadowDx="10"
    android:shadowDy="10"
    />
</LinearLayout>

No comments: