generate Thumb Color With Tint Color - Android Graphics

Android examples for Graphics:Color

Description

generate Thumb Color With Tint Color

Demo Code


//package com.java2s;
import android.content.res.ColorStateList;

public class Main {
    private static final int ENABLE_ATTR = android.R.attr.state_enabled;
    private static final int CHECKED_ATTR = android.R.attr.state_checked;
    private static final int PRESSED_ATTR = android.R.attr.state_pressed;

    public static ColorStateList generateThumbColorWithTintColor(
            final int tintColor) {
        int[][] states = new int[][] { { -ENABLE_ATTR, CHECKED_ATTR },
                { -ENABLE_ATTR }, { PRESSED_ATTR, -CHECKED_ATTR },
                { PRESSED_ATTR, CHECKED_ATTR }, { CHECKED_ATTR },
                { -CHECKED_ATTR } };/*from  w  w w. ja v  a2  s  . c om*/

        int[] colors = new int[] { tintColor - 0xAA000000, 0xFFBABABA,
                tintColor - 0x99000000, tintColor - 0x99000000,
                tintColor | 0xFF000000, 0xFFEEEEEE };
        return new ColorStateList(states, colors);
    }
}

Related Tutorials