Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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