游戏详情自定义栏目渐隐文字支持颜色继承
This commit is contained in:
@ -213,14 +213,19 @@ public class ExpandTextView extends AppCompatTextView {
|
||||
}
|
||||
}, startPosition + mEndText.length(), msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
int paintColor = paint.getColor();
|
||||
int paintColor = 0;
|
||||
|
||||
// 找到最后一个 ForegroundSpan 并获取颜色给 GradientAlphaTextSpan
|
||||
ForegroundColorSpan[] foregroundColorSpans = msp.getSpans(0, startPosition, ForegroundColorSpan.class);
|
||||
if (foregroundColorSpans.length != 0) {
|
||||
int endPosition = msp.getSpanEnd(foregroundColorSpans[foregroundColorSpans.length - 1]);
|
||||
Object[] objects = msp.getSpans(0, startPosition, Object.class);
|
||||
if (objects.length != 0) {
|
||||
Object span = objects[objects.length - 1];
|
||||
int endPosition = msp.getSpanEnd(span);
|
||||
if (endPosition == startPosition) {
|
||||
paintColor = foregroundColorSpans[foregroundColorSpans.length - 1].getForegroundColor();
|
||||
if (span instanceof ForegroundColorSpan) {
|
||||
paintColor = ((ForegroundColorSpan) span).getForegroundColor();
|
||||
} else if (span instanceof ClickableSpan) {
|
||||
paintColor = getResources().getColor(R.color.theme_font);
|
||||
}
|
||||
}
|
||||
}
|
||||
msp.setSpan(new GradientAlphaTextSpan(paintColor), startPosition, startPosition + finalEndText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
Reference in New Issue
Block a user