TextView Shadow 文字陰影
如果幫 TextView 中的文字加陰影。主要有四個參數可在 xml 中調整
android:shadowColor
android:shadowRadius
android:shadowDx
android:shadowDy
shadowColor 設定陰影的顏色
shadowRadius 設定陰影的粗度
shadowDx 設定陰影X方向的距離
shadowDy 設定陰影Y方向的距離
XML 範例
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="1"
android:shadowDx="10"
android:shadowDy="10"
/>
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="10"
android:shadowDx="10"
android:shadowDy="10"
/>
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="10"
android:shadowDx="1"
android:shadowDy="1"
/>
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="1"
android:shadowDx="-10"
android:shadowDy="-10"
/>
</LinearLayout>
結果
android:shadowColor
android:shadowRadius
android:shadowDx
android:shadowDy
shadowColor 設定陰影的顏色
shadowRadius 設定陰影的粗度
shadowDx 設定陰影X方向的距離
shadowDy 設定陰影Y方向的距離
XML 範例
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="1"
android:shadowDx="10"
android:shadowDy="10"
/>
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="10"
android:shadowDx="10"
android:shadowDy="10"
/>
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="10"
android:shadowDx="1"
android:shadowDy="1"
/>
<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/hello"
android:textColor="@drawable/red"
android:shadowColor="@drawable/white"
android:shadowRadius="1"
android:shadowDx="-10"
android:shadowDy="-10"
/>
</LinearLayout>
結果
留言
張貼留言