user1276092
user1276092

Reputation: 513

how to have blank spaces for android:text attribute value in xml

I had a scenario where I need to have spaces for android:text attribute value.
android:text="Input type" ---> I need output with 5 spaces between "Input" and "type" Strings
How can I achieve the above result.

Thanks in Advance

Upvotes: 0

Views: 2741

Answers (4)

Yyy
Yyy

Reputation: 2335

Add this   with your strings in xml file

<string name="stringsample">Sample:&#160;</string>

Upvotes: 1

ggueno
ggueno

Reputation: 71

It's better to use string ressources.

Put all your string value in a file on res/values/strings.xml.

If you want to add space you can do it by surround your text by double quotes.

You can see an example in the documentation : http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling

Upvotes: 1

Rohit
Rohit

Reputation: 3408

<TextView
    android:id="@+id/xxx"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/empty_spaces" />

in strings.

<string name="empty_spaces">Input\t\t type</string>

Upvotes: 2

Jena43
Jena43

Reputation: 85

You can replace spaces by \u0020

<TextView android:text="Input\u0020\u0020\u0020\u0020\u0020types" />

Upvotes: 1

Related Questions