Example usage for android.text.style ScaleXSpan ScaleXSpan

List of usage examples for android.text.style ScaleXSpan ScaleXSpan

Introduction

In this page you can find the example usage for android.text.style ScaleXSpan ScaleXSpan.

Prototype

public ScaleXSpan(@NonNull Parcel src) 

Source Link

Document

Creates a ScaleXSpan from a parcel.

Usage

From source file:Main.java

public static Spannable applyKerning(CharSequence src, float kerning, int start, int end) {
    if (src == null)
        return null;
    final int srcLength = src.length();
    if (srcLength < 2)
        return src instanceof Spannable ? (Spannable) src : new SpannableString(src);
    if (start < 0)
        start = 0;/* w  w w  . j  a v  a 2  s  .  com*/
    if (end > srcLength)
        end = srcLength;

    final String nonBreakingSpace = "\u00A0";
    final SpannableStringBuilder builder = src instanceof SpannableStringBuilder ? (SpannableStringBuilder) src
            : new SpannableStringBuilder(src);
    for (int i = src.length(); i >= 1; i--) {
        builder.insert(i, nonBreakingSpace);
        builder.setSpan(new ScaleXSpan(kerning), i, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    return builder;
}

From source file:de.schildbach.wallet.ui.CurrencyTextView.java

public void setPrefixScaleX(final float prefixScaleX) {
    this.prefixScaleXSpan = new ScaleXSpan(prefixScaleX);
    updateView();/*from w  w w. j  ava 2 s. co m*/
}