Created
September 2, 2014 10:43
-
-
Save alorma/c047e8bc4dc672eac515 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class CircleDrawable extends StateListDrawable { | |
public CircleDrawable() { | |
int stateFocused = android.R.attr.state_focused; | |
int statePressed = android.R.attr.state_pressed; | |
int stateSelected = android.R.attr.state_selected; | |
int stateDisabled = -android.R.attr.state_enabled; | |
int selectedColor = ColorHelper.getHexColorTransparent(getActivity(), "a4"); | |
addState(new int[]{stateSelected}, new CircleShape(selectedColor)); | |
addState(new int[]{statePressed}, new CircleShape(selectedColor)); | |
addState(new int[]{stateFocused}, new CircleShape(selectedColor)); | |
addState(new int[]{stateDisabled}, new CircleShape(Color.LTGRAY)); | |
addState(new int[]{-stateFocused, -statePressed, -stateSelected}, new CircleShape(getResources().getColor(R.color.color_emptyData))); | |
} | |
private class CircleShape extends ShapeDrawable { | |
public CircleShape(int color) { | |
super(new OvalShape()); | |
getPaint().setColor(color); | |
getPaint().setStyle(Paint.Style.FILL); | |
getPaint().setStrokeWidth(1); | |
getPaint().setAntiAlias(true); | |
setPadding(8, 8, 8, 8); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment