In this android example tutorial, we will see how to add shadow effect to text by using Kotlin in android studio.
Implementation:
To begin, Create a new project in android studio and enter the name, select the project location and language to Kotlin. Then press the Finish button.
Open the activity_shadow_effect_text.xml file and add the LinearLayout with orientation (Vertical or horizontal).
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
In activity_shadow_effect_text.xml file, insert an TextView inside a LinearLayout.
<TextView |
For add shadow in text you have to use shadowColor , shadowDx and shadowDy property and set radius of radius by using shadowRadius attribute.
android:shadowDx="8" |
TextView in android has the following properties:
id, padding, textSize, text, textColor, shadowDy, shadowRadius, fontFamily, textStyle, layout_margin etc.
android:padding="10dp" |
Now run the application, you will see the output shown below.
Output:
Complete source code for Shadow Effect on Text Android example:
activity_shadow_effect_text.xml file
<?xml version="1.0" encoding="utf-8"?> <TextView |
Conclusion: We have covered the topic how to add Shadow Effect on Text to Android by using Kotlin.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#F4F4EB"
tools:context=".ShadowEffectText">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kotlin Developer"
android:textSize="29sp"
android:textColor="@color/black"
android:shadowDx="8"
android:shadowDy="6"
android:shadowRadius="4"
android:shadowColor="#D64A4A"
></TextView>
</LinearLayout>
Conclusion: We have covered the topic how to add Shadow Effect on Text to Android by using Kotlin.
-->
Article Contributed By :
|
|
|
|
1187 Views |