我能够在android中创建子弹跨度。这是我所取得成就的快照
如何缩进以确保跨越多行的列表项不会与此快照中显示的项目符号的同一点开始?
这是我的代码
String description="";
for (JsonElement e:sl.get("description").getAsJsonArray()){
if(!e.getAsString().trim().isEmpty() && CharMatcher.javaUpperCase().or(CharMatcher.javaLetter().negate()).matchesAllOf(e.getAsString().trim())) {
SpannableString s1 = new SpannableString(e.getAsString());
s1.setSpan(new BulletSpan(20), 1, e.getAsString().length(), 0);
description +=s1 + "\n\n";
}else if(!e.getAsString().trim().isEmpty()) {
SpannableString s1 = new SpannableString(e.getAsString());
s1.setSpan(new BulletSpan(20), 1, e.getAsString().length(), 0);
description += "\u25CF " +" "+ s1 + "\n\n";
}
}
viewHolder.body.setText(description);
viewHolder.body.setTypeface(tf);
这是xml
<me.biubiubiu.justifytext.library.JustifyTextView
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_vertical"
android:layout_below="@+id/thumbnail"
android:textColor="@color/black"
android:textSize="16sp"/>
答案 0 :(得分:1)
在设置LeadingMarginSpan
之前先实施BulletSpan
:
s1.setSpan(new LeadingMarginSpan.Standard(30, 60), 1, s1.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)