ScaleXSpan

水平方向上拉升的样式。

ScaleXSpan(int proportion):比例。

ScaleXSpan(Parcel src):参数src,包含有proportion值的包装类。

示例1:

ScaleXSpan scaleXSpan = new ScaleXSpan(2.5f);

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(scaleXSpan, 2, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

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

示例2:

Parcel parcel = Parcel.obtain();
parcel.writeFloat(2.5f);
parcel.setDataPosition(0);
ScaleXSpan scaleXSpan = new ScaleXSpan(parcel);

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(scaleXSpan, 2, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

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

示例3:

重写updateDrawState(TextPaint textPaint)方法,修改删除线的样式、文本颜色:

ScaleXSpan scaleXSpan = new ScaleXSpan(2.5f) {
    @Override
    public void updateDrawState(TextPaint textPaint) {
        super.updateDrawState(textPaint);
        textPaint.setColor(Color.argb(255, 54, 92, 124));
    }
};

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(scaleXSpan, 2, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

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