Example usage for android.content.res ColorStateList ColorStateList

List of usage examples for android.content.res ColorStateList ColorStateList

Introduction

In this page you can find the example usage for android.content.res ColorStateList ColorStateList.

Prototype

public ColorStateList(int[][] states, @ColorInt int[] colors) 

Source Link

Document

Creates a ColorStateList that returns the specified mapping from states to colors.

Usage

From source file:Main.java

public static ColorStateList createColorStateList(int color, int pressed) {
    return new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, new int[] {} },
            new int[] { pressed, color });
}

From source file:Main.java

public static ColorStateList getPressedColorSelector(int paramInt1, int paramInt2) {
    return new ColorStateList(new int[][] { { 16842919 }, { 16842908 }, { 16843518 }, new int[0] },
            new int[] { paramInt2, paramInt2, paramInt2, paramInt1 });
}

From source file:Main.java

/**
 * helper to create a colorStateList for the text
 *
 * @param text_color// w w  w . j  a v  a  2 s . c  o  m
 * @param selected_text_color
 * @return
 */
public static ColorStateList getTextColorStateList(int text_color, int selected_text_color) {
    return new ColorStateList(new int[][] { new int[] { android.R.attr.state_selected }, new int[] {} },
            new int[] { selected_text_color, text_color });
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static ColorStateList createActivatedColor(int passive, int active) {
    return new ColorStateList(new int[][] { new int[] { android.R.attr.state_activated }, StateSet.WILD_CARD },
            new int[] { active, passive });
}

From source file:Main.java

public static ColorStateList createColorStateList(int normal, int pressed) {
    int[] colors = new int[] { pressed, normal };
    int[][] states = new int[2][];
    states[0] = new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled };
    states[1] = new int[] {};
    return new ColorStateList(states, colors);
}

From source file:Main.java

/**
 * Generate text color color state list.
 *
 * @param pressColor   the press color//w  ww. j  a va  2 s  . c o m
 * @param defaultColor the default color
 * @return the color state list
 */
public static ColorStateList generateTextColor(int pressColor, int defaultColor) {
    ColorStateList stateList = new ColorStateList(new int[][] { { android.R.attr.state_pressed }, {} },
            new int[] { pressColor, defaultColor });
    return stateList;
}

From source file:Main.java

public static ColorStateList createColorStateList(int colorNormal, int colorPressed) {
    int[] colors = new int[] { colorPressed, colorNormal };
    int[][] states = new int[2][];
    states[0] = new int[] { android.R.attr.state_pressed };
    states[1] = new int[] {};
    ColorStateList colorList = new ColorStateList(states, colors);
    return colorList;
}

From source file:Main.java

private static ColorStateList createColorStateList(int checked, int normal) {
    int[] colors = new int[] { checked, normal };
    int[][] states = new int[2][];
    states[0] = new int[] { android.R.attr.state_checked, android.R.attr.state_enabled };
    states[1] = new int[] {};
    return new ColorStateList(states, colors);
}

From source file:Main.java

public static ColorStateList wrapColor(int newPrimaryColor) {
    int[][] states = new int[][] { new int[] { -android.R.attr.state_enabled }, // disabled
            new int[] {} // enabled
    };//from ww w. j  av  a 2 s .  com
    int[] colors = new int[] { adjustAlpha(newPrimaryColor, 0.4f), newPrimaryColor };
    return new ColorStateList(states, colors);
}

From source file:Main.java

public static ColorStateList getPressedColorSelector(int normalColor, int pressedColor) {
    return new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed },
            new int[] { android.R.attr.state_focused }, new int[] { android.R.attr.state_activated },
            new int[] {} }, new int[] { pressedColor, pressedColor, pressedColor, normalColor });
}