How do I indent a text line in TextView in android?
android
Solution
Use a `LeadingMarginSpan.Standard` with a `SpannableString`, or if you also need bullets use a `BulletSpan`:
Just create a function like this:
static SpannableString createIndentedText(String text, int marginFirstLine, int marginNextLines) {
SpannableString result=new SpannableString(text);
result.setSpan(new LeadingMarginSpan.Standard(marginFirstLine, marginNextLines),0,text.length(),0);
return result;
}
And then, everytime you need an indented line you can do:
myTextView.setText(createIndentedText("my text that's gonna be indented", 10, 10));
The first parameter is the indentation of the first line, the second parameter is the indentation of the next lines, just in case you want to indent the first line differently to the following ones.
Problem
I am writing a text in android which take more than two lines now my problem is how I indent the second line my text lines are. ``` 1.my name is qadeer hussain iam fine how Ru. ``` but I want ``` 1.my name is qadeer hussain iam fine how Ru. ``` here the second line not start right below the one but it right below the name