LeadingMarginSpan

LeadingMarginSpan.Standard,文本缩进的样式。有3个构造函数,分别为:

LeadingMarginSpan.Standard(int every):参数every,每行缩进的像素。

LeadingMarginSpan.Standard(int first, int rest):参数first,首行缩进的像素,rest,剩余行缩进的像素。

LeadingMarginSpan.Standard(Parcel src):参数src,包含有first和rest值的包装类。

示例1:

LeadingMarginSpan.Standard leadingMarginSpan = new LeadingMarginSpan.Standard(20);
//LeadingMarginSpan.Standard leadingMarginSpan = new LeadingMarginSpan.Standard(20, 20);

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(leadingMarginSpan, 0, 0, Spanned.SPAN_INCLUSIVE_INCLUSIVE);

TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(spannableString);

示例2:

Parcel parcel = Parcel.obtain();
parcel.writeInt(20);
parcel.writeInt(0);
parcel.setDataPosition(0);
LeadingMarginSpan.Standard leadingMarginSpan = new LeadingMarginSpan.Standard(parcel);

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(leadingMarginSpan, 0, 0, Spanned.SPAN_INCLUSIVE_INCLUSIVE);

TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(spannableString);