Example usage for android.widget TextView setTextSize

List of usage examples for android.widget TextView setTextSize

Introduction

In this page you can find the example usage for android.widget TextView setTextSize.

Prototype

public void setTextSize(int unit, float size) 

Source Link

Document

Set the default text size to a given unit and value.

Usage

From source file:Main.java

public static void setTextViewAttributes(TextView textView, int size, int colorRes) {
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
    textView.setTextColor(textView.getResources().getColor(colorRes));
}

From source file:Main.java

public static void changeTextSize(final TextView textView, float from, float to) {
    ValueAnimator textSizeChangeAnimator = ValueAnimator.ofFloat(from, to);
    textSizeChangeAnimator.setDuration(150);
    textSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/* w  ww . j  ava  2 s .co m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) valueAnimator.getAnimatedValue());
        }
    });
    textSizeChangeAnimator.start();
}

From source file:Main.java

static void changeTextSize(final TextView textView, float from, float to) {
    ValueAnimator textSizeChangeAnimator = ValueAnimator.ofFloat(from, to);
    textSizeChangeAnimator.setDuration(150);
    textSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*  www  . j a  v  a  2  s  .c om*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) valueAnimator.getAnimatedValue());
        }
    });
    textSizeChangeAnimator.start();
}

From source file:Main.java

public static void setTitle(TextView titleTv, int titleColor, int titleTextSize, int messageColor,
        int messageTextSize, CharSequence title, CharSequence message) {
    titleTv.setMinHeight(titleTextSize * 3);

    if (!TextUtils.isEmpty(title) && TextUtils.isEmpty(message)) {
        titleTv.setTextColor(titleColor);
        titleTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
        titleTv.getPaint().setFakeBoldText(true);
        titleTv.setText(title);/*from w ww.  j a  v a 2 s. c o  m*/
    } else if (TextUtils.isEmpty(title) && !TextUtils.isEmpty(message)) {
        titleTv.setTextColor(messageColor);
        titleTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, messageTextSize);
        titleTv.setText(message);
    } else if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(message)) {
        SpannableString titleSs = new SpannableString(title + "\n" + message);
        titleSs.setSpan(new ForegroundColorSpan(titleColor), 0, title.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleSs.setSpan(new AbsoluteSizeSpan(titleTextSize), 0, title.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleSs.setSpan(new StyleSpan(Typeface.BOLD), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        titleSs.setSpan(new ForegroundColorSpan(messageColor), title.length(), titleSs.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleSs.setSpan(new AbsoluteSizeSpan(messageTextSize), title.length(), titleSs.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleTv.setText(titleSs);
        titleTv.setLineSpacing(0.0f, 1.2f);
    } else {
        titleTv.setVisibility(View.GONE);
    }
}

From source file:mp.paschalis.App.java

public static void setStyleDirection(TextView pTextView) {
    pTextView.setTextColor(Color.WHITE);
    pTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);

}

From source file:mp.paschalis.App.java

public static void setStyleSuccessDirection(TextView pTextView) {
    setStyleSuccessDirectionColor(pTextView);
    pTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);

}

From source file:mp.paschalis.App.java

public static void setStyleErrorDirection(TextView pTextView) {
    pTextView.setTextColor(Color.parseColor("#C2022C"));
    pTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);

}

From source file:com.android.inputmethod.keyboard.emoji.EmojiPalettesView.java

private static void setupAlphabetKey(final TextView alphabetKey, final String label,
        final KeyDrawParams params) {
    alphabetKey.setText(label);//from   w  ww .ja  va 2 s . c om
    alphabetKey.setTextColor(params.mFunctionalTextColor);
    alphabetKey.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize);
    alphabetKey.setTypeface(params.mTypeface);
}

From source file:am.project.x.business.widgets.tagtabstrip.TagTabStripActivity.java

private ArrayList<View> getPagers() {
    ArrayList<View> views = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        TextView text = new TextView(this);
        text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180);
        text.setText(String.format(Locale.getDefault(), "%d", i + 1));
        text.setGravity(Gravity.CENTER);
        text.setTextColor(0xff000000);// www  .  j  ava2 s. c  o  m
        views.add(text);
    }
    return views;
}

From source file:am.project.x.business.widgets.indicatortabstrip.IndicatorTabStripActivity.java

private ArrayList<View> getPagers() {
    ArrayList<View> views = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        TextView text = new TextView(this);
        text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180);
        text.setText(String.format(Locale.getDefault(), "%d", i + 1));
        text.setGravity(Gravity.CENTER);
        text.setTextColor(0xff000000);//from w  w w . j  ava 2  s  .c om
        views.add(text);
    }
    return views;
}