Example usage for android.widget TextView setTextColor

List of usage examples for android.widget TextView setTextColor

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setTextColor(ColorStateList colors) 

Source Link

Document

Sets the text color.

Usage

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static void addImgLinkText(final Context context, ArrayList<View> views, final String url,
        LinearLayout.LayoutParams params) {
    final TextView textView = new TextView(context);
    textView.setTextColor(Color.BLUE);
    textView.setLayoutParams(params);/*from   ww w .  j  a  v a  2  s. c  om*/
    textView.setText("View image");
    textView.setTextSize(getTextSize(context));
    textView.setPadding(3, 3, 3, 3);
    textView.setTag(url);
    textView.setClickable(true);
    setupOnLinkClick(context, url, textView);
    views.add(textView);
}

From source file:Main.java

/**
 * Update text color with animation//w  w  w . java2  s  .  c o m
 */
public static void updateTextColor(final TextView textView, int fromColor, int toColor) {
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    colorAnimation.setDuration(150);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            textView.setTextColor((Integer) animator.getAnimatedValue());
        }
    });
    colorAnimation.start();
}

From source file:Main.java

public static void changeTextColor(final TextView textView, int fromColor, int toColor) {
    ValueAnimator changeTextColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    changeTextColorAnimation.setDuration(150);
    changeTextColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//from   w w w. j  a  v a2 s.  c  o  m
        public void onAnimationUpdate(ValueAnimator animator) {
            textView.setTextColor((Integer) animator.getAnimatedValue());
        }
    });
    changeTextColorAnimation.start();
}

From source file:Main.java

static void changeTextColor(final TextView textView, int fromColor, int toColor) {
    ValueAnimator changeTextColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    changeTextColorAnimation.setDuration(150);
    changeTextColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//from   w  w  w. ja v  a 2  s .c  om
        public void onAnimationUpdate(ValueAnimator animator) {
            textView.setTextColor((Integer) animator.getAnimatedValue());
        }
    });
    changeTextColorAnimation.start();
}

From source file:com.bt.download.android.gui.util.UIUtils.java

/**
 * Android devices with SDK below target=11 do not support textView.setAlpha().
 * This is a work around. //www.  j  a  v  a  2s .  com
 * @param v - the text view
 * @param alpha - a value from 0 to 255. (0=transparent, 255=fully visible)
 */
public static void setTextViewAlpha(TextView v, int alpha) {
    v.setTextColor(v.getTextColors().withAlpha(alpha));
    v.setHintTextColor(v.getHintTextColors().withAlpha(alpha));
    v.setLinkTextColor(v.getLinkTextColors().withAlpha(alpha));

    Drawable[] compoundDrawables = v.getCompoundDrawables();
    for (int i = 0; i < compoundDrawables.length; i++) {
        Drawable d = compoundDrawables[i];
        if (d != null) {
            d.setAlpha(alpha);
        }
    }

}

From source file:Main.java

protected static Bitmap creatCodeBitmap(String contents, int width, int height, Context context) {
    TextView tv = new TextView(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    tv.setLayoutParams(layoutParams);// ww w .ja va2  s  . c  o m
    tv.setText(contents);
    tv.setHeight(height);
    tv.setGravity(Gravity.CENTER_HORIZONTAL);
    tv.setWidth(width);
    tv.setDrawingCacheEnabled(true);
    tv.setTextColor(Color.BLACK);
    tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());

    tv.buildDrawingCache();
    Bitmap bitmapCode = tv.getDrawingCache();
    return bitmapCode;
}

From source file:mp.paschalis.App.java

public static void setStyleSuccessDirectionColor(TextView pTextView) {
    pTextView.setTextColor(Color.parseColor("#ff33b5e5"));
}

From source file:mp.paschalis.App.java

public static void setStyleErrorDirectionColor(TextView pTextView) {
    pTextView.setTextColor(Color.parseColor("#C2022C"));

}

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:mp.paschalis.App.java

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

}