urbanairship-core/src/main/java/com/urbanairship/iam/view/InAppViewUtils.java
public static void applyTextInfo(@NonNull TextView textView, @NonNull TextInfo textInfo) {

        if (textInfo.getFontSize() != null) {
            textView.setTextSize(textInfo.getFontSize());
        }

        if (textInfo.getColor() != null) {
            textView.setTextColor(textInfo.getColor());
        }

        Drawable drawable = null;
        if (textInfo.getDrawable() != 0) {
            drawable = ContextCompat.getDrawable(textView.getContext(), textInfo.getDrawable());
        }

        if (drawable != null) {
            int size = Math.round(textView.getTextSize());
            int color = textView.getCurrentTextColor();

            try {
                Drawable wrappedDrawable = DrawableCompat.wrap(drawable).mutate();
                wrappedDrawable.setBounds(0, 0, size, size);
                wrappedDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);

                CenteredImageSpan imageSpan = new CenteredImageSpan(wrappedDrawable);
                SpannableString text;

                if (textInfo.getText() == null) {
                    text = new SpannableString(" ");
                    text.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                } else {
                    text = new SpannableString("  " + textInfo.getText());
                    text.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    text.setSpan(new RemoveUnderlineSpan(), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }

                textView.setText(text);
            } catch (Resources.NotFoundException e) {
                Logger.error("Unable to find button drawable.", e);
                textView.setText(textInfo.getText());
            }
        } else {
            textView.setText(textInfo.getText());
        }


        int typefaceFlags = textView.getTypeface() == null ? Typeface.NORMAL : textView.getTypeface().getStyle();
        int paintFlags = textView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG;

        for (@TextInfo.Style String style : textInfo.getStyles()) {
            switch (style) {
                case TextInfo.STYLE_BOLD:
                    typefaceFlags |= Typeface.BOLD;
                    break;
                case TextInfo.STYLE_ITALIC:
                    typefaceFlags |= Typeface.ITALIC;
                    break;
                case TextInfo.STYLE_UNDERLINE:
                    paintFlags |= Paint.UNDERLINE_TEXT_FLAG;
                    break;
            }
        }

        if (textInfo.getAlignment() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            switch (textInfo.getAlignment()) {
                case TextInfo.ALIGNMENT_CENTER:
                    textView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
                    break;

                case TextInfo.ALIGNMENT_LEFT:
                    textView.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    break;

                case TextInfo.ALIGNMENT_RIGHT:
                    textView.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_END);
                    break;
            }
        }

        Typeface typeface = getTypeFace(textView.getContext(), textInfo.getFontFamilies());
        if (typeface == null) {
            typeface = textView.getTypeface();
        }

        textView.setTypeface(typeface, typefaceFlags);
        textView.setPaintFlags(paintFlags);
    }
/**
     * Applies text info to a text view.
     *
     * @param textView The text view.
     * @param textInfo The text info.
     */
Applies text info to a text view.
@param textView The text view.
@param textInfo The text info.
Applies text info to a text view . @param textView The text view . @param textInfo The text info .
public static void applyTextInfo(@NonNull TextView textView, @NonNull TextInfo textInfo) {
        if (textInfo.getFontSize() != null) {
            textView.setTextSize(textInfo.getFontSize());
        }
        if (textInfo.getColor() != null) {
            textView.setTextColor(textInfo.getColor());
        }
        Drawable drawable = null;
        if (textInfo.getDrawable() != 0) {
            drawable = ContextCompat.getDrawable(textView.getContext(), textInfo.getDrawable());
        }
        if (drawable != null) {
            int size = Math.round(textView.getTextSize());
            int color = textView.getCurrentTextColor();
            try {
                Drawable wrappedDrawable = DrawableCompat.wrap(drawable).mutate();
                wrappedDrawable.setBounds(0, 0, size, size);
                wrappedDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
                CenteredImageSpan imageSpan = new CenteredImageSpan(wrappedDrawable);
                SpannableString text;
                if (textInfo.getText() == null) {
                    text = new SpannableString(" ");
                    text.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                } else {
                    text = new SpannableString("  " + textInfo.getText());
                    text.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    text.setSpan(new RemoveUnderlineSpan(), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                textView.setText(text);
            } catch (Resources.NotFoundException e) {
                Logger.error("Unable to find button drawable.", e);
                textView.setText(textInfo.getText());
            }
        } else {
            textView.setText(textInfo.getText());
        }
        int typefaceFlags = textView.getTypeface() == null ? Typeface.NORMAL : textView.getTypeface().getStyle();
        int paintFlags = textView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG;
        for (@TextInfo.Style String style : textInfo.getStyles()) {
            switch (style) {
                case TextInfo.STYLE_BOLD:
                    typefaceFlags |= Typeface.BOLD;
                    break;
                case TextInfo.STYLE_ITALIC:
                    typefaceFlags |= Typeface.ITALIC;
                    break;
                case TextInfo.STYLE_UNDERLINE:
                    paintFlags |= Paint.UNDERLINE_TEXT_FLAG;
                    break;
            }
        }
        if (textInfo.getAlignment() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            switch (textInfo.getAlignment()) {
                case TextInfo.ALIGNMENT_CENTER:
                    textView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
                    break;
                case TextInfo.ALIGNMENT_LEFT:
                    textView.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    break;
                case TextInfo.ALIGNMENT_RIGHT:
                    textView.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_END);
                    break;
            }
        }
        Typeface typeface = getTypeFace(textView.getContext(), textInfo.getFontFamilies());
        if (typeface == null) {
            typeface = textView.getTypeface();
        }
        textView.setTypeface(typeface, typefaceFlags);
        textView.setPaintFlags(paintFlags);
    }
public static void applyTextInfo ( @ NonNull TextView textView , @ NonNull TextInfo textInfo ) { if ( textInfo . getFontSize ( ) != null ) { textView . setTextSize ( textInfo . getFontSize ( ) ) ; } if ( textInfo . getColor ( ) != null ) { textView . setTextColor ( textInfo . getColor ( ) ) ; } Drawable drawable = null ; if ( textInfo . getDrawable ( ) != 0 ) { drawable = ContextCompat . getDrawable ( textView . getContext ( ) , textInfo . getDrawable ( ) ) ; } if ( drawable != null ) { int size = Math . round ( textView . getTextSize ( ) ) ; int color = textView . getCurrentTextColor ( ) ; try { Drawable wrappedDrawable = DrawableCompat . wrap ( drawable ) . mutate ( ) ; wrappedDrawable . setBounds ( 0 , 0 , size , size ) ; wrappedDrawable . setColorFilter ( color , PorterDuff . Mode . MULTIPLY ) ; CenteredImageSpan imageSpan = new CenteredImageSpan ( wrappedDrawable ) ; SpannableString text ; if ( textInfo . getText ( ) == null ) { text = new SpannableString ( " " ) ; text . setSpan ( imageSpan , 0 , 1 , Spannable . SPAN_EXCLUSIVE_EXCLUSIVE ) ; } else { text = new SpannableString ( "  " + textInfo . getText ( ) ) ; text . setSpan ( imageSpan , 0 , 1 , Spannable . SPAN_EXCLUSIVE_EXCLUSIVE ) ; text . setSpan ( new RemoveUnderlineSpan ( ) , 1 , 2 , Spannable . SPAN_EXCLUSIVE_EXCLUSIVE ) ; } textView . setText ( text ) ; } catch ( Resources . NotFoundException e ) { Logger . error ( "Unable to find button drawable." , e ) ; textView . setText ( textInfo . getText ( ) ) ; } } else { textView . setText ( textInfo . getText ( ) ) ; } int typefaceFlags = textView . getTypeface ( ) == null ? Typeface . NORMAL : textView . getTypeface ( ) . getStyle ( ) ; int paintFlags = textView . getPaintFlags ( ) | Paint . ANTI_ALIAS_FLAG | Paint . SUBPIXEL_TEXT_FLAG ; for ( @ TextInfo . Style String style : textInfo . getStyles ( ) ) { switch ( style ) { case TextInfo . STYLE_BOLD : typefaceFlags |= Typeface . BOLD ; break ; case TextInfo . STYLE_ITALIC : typefaceFlags |= Typeface . ITALIC ; break ; case TextInfo . STYLE_UNDERLINE : paintFlags |= Paint . UNDERLINE_TEXT_FLAG ; break ; } } if ( textInfo . getAlignment ( ) != null && Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR1 ) { switch ( textInfo . getAlignment ( ) ) { case TextInfo . ALIGNMENT_CENTER : textView . setTextAlignment ( View . TEXT_ALIGNMENT_CENTER ) ; break ; case TextInfo . ALIGNMENT_LEFT : textView . setTextAlignment ( View . TEXT_ALIGNMENT_TEXT_START ) ; break ; case TextInfo . ALIGNMENT_RIGHT : textView . setTextAlignment ( View . TEXT_ALIGNMENT_TEXT_END ) ; break ; } } Typeface typeface = getTypeFace ( textView . getContext ( ) , textInfo . getFontFamilies ( ) ) ; if ( typeface == null ) { typeface = textView . getTypeface ( ) ; } textView . setTypeface ( typeface , typefaceFlags ) ; textView . setPaintFlags ( paintFlags ) ; }
Applies text info to a text view.
Applies text info to a text view .