我使用quoteSpan作为textView
SpannableString t1 = new SpannableString(Html.fromHtml(myItems.get(position).getTest()));
t1.setSpan(new QuoteSpan(Color.RED), 0, t1.length(), Spannable.SPAN_PARAGRAPH);
txtView1.setText(t1);
但它在文本的左侧显示了一条非常细的线条,有没有办法让这条线变粗,以便它看起来更好?
答案 0 :(得分:0)
使用接受包裹的Quote Span类构造函数并使用以下Java代码:
Parcel parcel = Parcel.obtain();
parcel.writeInt(getColor(R.color.colorAccent));//stripe color
parcel.writeInt(10);//stripe width
parcel.writeInt(10);//gap width
parcel.setDataPosition(0);
QuoteSpan quoteSpan = new QuoteSpan(parcel);
SpannableString string = new SpannableString(getString(R.string.top_review));
string.setSpan(quoteSpan, 0, string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
((TextView) findViewById(R.id.quoteSpan)).setText(string);
parcel.recycle(); // put the parcel object back in the pool
如果要在Kotlin中查看此存储库: Custom Android Quote Span with AppCompat support