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
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.
Try using a \t
before what you want to indent. Use more if you need to indent it further
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With