Tommy Chong
Tommy Chong

Reputation: 386

How to underline the space of a string with spacing

In android xml how to underline the string with the spacing? If I using the underscore it will look not nicely because there are some gap between the underscore.

Example below are the underline that have gaps

enter image description here

Example below are the one that I looking for:

enter image description here

Upvotes: 0

Views: 256

Answers (2)

Parth Suthar
Parth Suthar

Reputation: 123

Make drawable for underscore line and set between that views.

Or use like this

TextView tv = (TextView) findViewById(R.id.tv);
        tv.setText(Html.fromHtml("Go<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u>Travel"));

The output is :

Go_______Travel

Upvotes: 1

Bhavesh Patadiya
Bhavesh Patadiya

Reputation: 25830

String temp = "Go     Travel"   
temp=temp.replaceAll(" ", "_"); // return Go______Travel

Note that it is just the simple logic, you can obviously use many other solutions based on your application/business logic.

Hope it helps.

Upvotes: 0

Related Questions