Created
January 31, 2017 10:16
-
-
Save baz8080/86d6023c74ed70d9408ea500b8577376 to your computer and use it in GitHub Desktop.
Creating ColorStateList programatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int[][] states = new int[][] { | |
new int[] { android.R.attr.state_enabled }, | |
new int[] { -android.R.attr.state_enabled } | |
}; | |
int[] coloursLight = new int[] { | |
Color.argb(255, 255, 255, 255), // White, active, 100% opaque | |
Color.argb(128, 255, 255, 255) // White, inactive, 50% opaque | |
}; | |
int[] coloursDark = new int[] { | |
Color.argb(138, 0, 0, 0), // Black, active, 54% opaque | |
Color.argb(66, 0, 0, 0) // Black, inactive, 26% opaque | |
}; | |
ColorStateList lightColourStateList = new ColorStateList(states, coloursLight); | |
ColorStateList darkColourStateList = new ColorStateList(states, coloursDark); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment