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.