sketchub icon

Dashed Underline under TextView

CoCoCo_CoCoCo
10 Likes
0 Comments
39 Downloads

Screenshots

About

How to Create Dashed Underline under TextView in Android?

In this article, we will explain how to create a dashed underline below a text view in android. A sample image is shown below to give an idea of what we are going to build.

  • Inject: TextView1 to tv_dashed

  • android:background="@drawable/dashed_underline"

  • Go to res > drawable > new > drawable resource file and create a new file and name it “dashed_underline.xml

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android&quot; > <!--Create a layer list and add item of shape "Rectangle to it"--> <item android:left="-5dp" android:right="-5dp" android:top="-5dp"> <shape android:shape="rectangle"> <!--Give the dashed lines their property like color, width, and dashGap--> <stroke android:color="#18191B" android:dashWidth="2dp" android:dashGap="3dp" android:width="2dp"/> </shape> </item> </layer-list>

©2025 Sketchub | User Policy