Possible Duplicate:
Android - shadow on text?
How can i make shadow effect text in a TextView
.
Any Idea?
You can give -/+ values, where -Dx draws a shadow on the left of text and +Dx on the right. android:shadowDy specifies the Y-axis offset of shadow. -Dy specifies a shadow above the text and +Dy specifies below the text.
CSS Syntaxtext-shadow: h-shadow v-shadow blur-radius color|none|initial|inherit; Note: To add more than one shadow to the text, add a comma-separated list of shadows.
put these in values/colors.xml
<resources>
<color name="light_font">#FBFBFB</color>
<color name="grey_font">#ff9e9e9e</color>
<color name="text_shadow">#7F000000</color>
<color name="text_shadow_white">#FFFFFF</color>
</resources>
Then in your layout xml here are some example TextView's
Example of Floating text on Light with Dark shadow
<TextView android:id="@+id/txt_example1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="@color/light_font"
android:shadowColor="@color/text_shadow"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2" />
Example of Etched text on Light with Dark shadow
<TextView android:id="@+id/txt_example2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="@color/light_font"
android:shadowColor="@color/text_shadow"
android:shadowDx="-1"
android:shadowDy="-1"
android:shadowRadius="1" />
Example of Crisp text on Light with Dark shadow
<TextView android:id="@+id/txt_example3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="@color/grey_font"
android:shadowColor="@color/text_shadow_white"
android:shadowDx="-2"
android:shadowDy="-2"
android:shadowRadius="1" />
Notice the positive and negative values... I suggest to play around with the colors/values yourself but ultimately you can adjust these settings to get the effect your looking for.
Perhaps you'd consider using android:shadowColor, android:shadowDx
, android:shadowDy
, android:shadowRadius
; alternatively setShadowLayer() ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With