Share this post on:

Here you will Get the source code of TextView in Android Studio. we will design the TextView in Linear layout. we will design the textview design in Drawable Resource

TextView in Android Studio
  1. Xml Design in Android Studio
<?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"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:layout_marginBottom="10dp"
android:background="#F3EBEB">

<!-- Simple TextView Deign-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Design"
android:textSize="14sp"
android:padding="6dp"
android:gravity="center"
android:drawableRight="@drawable/android_vector"
android:drawableTint="@color/black"
android:textColor="@color/black">
</TextView>

<!-- Design In TextView BackGround-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Design"
android:textSize="14sp"
android:padding="6dp"
android:drawableRight="@drawable/android_vector"
android:drawableTint="@color/white"
android:gravity="center"
android:layout_marginTop="8dp"
android:background="@color/teal_700"
android:textColor="@color/black">
</TextView>

<!-- Design in TextView using designsheet-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Design"
android:textSize="14sp"
android:padding="6dp"
android:gravity="center"
android:drawableLeft="@drawable/android_vector"
android:drawableTint="@color/white"
android:layout_marginTop="8dp"
android:background="@drawable/textview_backgrounddesign"
android:textColor="@color/black">
</TextView>

<!-- Design in TextView using designSheet-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Design"
android:textSize="14sp"
android:padding="6dp"
android:gravity="center"
android:drawableLeft="@drawable/android_vector"
android:drawableTint="@color/white"
android:layout_marginTop="8dp"
android:background="@drawable/textviewdesign_radius"
android:textColor="@color/black">
</TextView>

<!-- Design using dotted Side-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Design"
android:textSize="14sp"
android:padding="6dp"
android:gravity="center"
android:layout_marginTop="8dp"
android:background="@drawable/textviewdesign_dotted"
android:textColor="@color/black">
</TextView>

<!-- Design using Dotted side with background Color-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Design"
android:textSize="14sp"
android:padding="6dp"
android:gravity="center"
android:layout_marginTop="8dp"
android:background="@drawable/textviewdesign_dottedwithcolor"
android:textColor="@color/black">
</TextView>

<!-- Design using different color-->

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simple Text Design"
android:textSize="14sp"
android:padding="6dp"
android:gravity="center"
android:layout_marginTop="8dp"
android:background="@drawable/textviewdesign_usingdifferentcolor"
android:textColor="@color/black">
</TextView>

</LinearLayout>

2. TextView Design of drawable resources: textview_backgrounddesign

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#0FD5F3"></solid>

<corners android:radius="10dp">
</corners>

</shape>

3. TextView Design of drawable resources: textviewdesign_radius

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00B8D4"></solid>

<corners android:topLeftRadius="10dp"
android:bottomRightRadius="10dp">
</corners>

</shape>

4. TextView Design of drawable resources: textviewdesign_dotted

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<stroke android:width="2dp"
android:color="#070707"
android:dashWidth="10dp"
android:dashGap="5dp"></stroke>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp"></padding>
<corners android:radius="10dp">
</corners>
</shape>

5. TextView Design of drawable resources: textviewdesign_dottedwithcolor

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="#B8E6ED"></solid>
<stroke android:width="2dp"
android:color="#C51162"
android:dashWidth="10dp"
android:dashGap="5dp"></stroke>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp"></padding>
<corners android:radius="10dp">
</corners>
</shape>

6. TextView Design of drawable resources: textviewdesign_usingdifferentcolor

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#06D2F1"
android:centerColor="#E6A2C1"
android:endColor="#BB6FE1">
</gradient>

<corners android:radius="10dp">
</corners>

</shape>
Share this post on:
Avatar Raiyan

Author: Raiyan

Hi, I guess you're here because you want to know a bit about me. huh? I am not so good on talking about myself but I'll give a short about me.

My Name is Raiyan. I am a Professional Application Developer and a Blogger.
I started this website to Share my Knowledge. Here I provide all my knowledge whatever I earned till now.

Leave a Comment

Your email address will not be published. Required fields are marked *