Android 用户协议字体颜色

    TextView protocol = findViewById(R.id.tv_protocol);
    SpannableStringBuilder builder = new SpannableStringBuilder(protocol.getText().toString());
    ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.BLUE);
    UnderlineSpan underlineSpan = new UnderlineSpan();
    builder.setSpan(foregroundColorSpan, 8, 16, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(underlineSpan, 8, 16, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    protocol.setText(builder);

参考资料:
https://blog.csdn.net/duoduo_11011/article/details/71084765

你可能感兴趣的:(Android 用户协议字体颜色)