Skip to content

Instantly share code, notes, and snippets.

@alorma
Created September 2, 2014 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alorma/c047e8bc4dc672eac515 to your computer and use it in GitHub Desktop.
Save alorma/c047e8bc4dc672eac515 to your computer and use it in GitHub Desktop.
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