MCPcopy Create free account
hub / github.com/Cutta/TagView / getSelector

Method getSelector

library/src/main/java/com/cunoraz/tagview/TagView.java:281–299  ·  view source on GitHub ↗
(Tag tag)

Source from the content-addressed store, hash-verified

279 }
280
281 private Drawable getSelector(Tag tag) {
282 if (tag.background != null)
283 return tag.background;
284
285 StateListDrawable states = new StateListDrawable();
286 GradientDrawable gdNormal = new GradientDrawable();
287 gdNormal.setColor(tag.layoutColor);
288 gdNormal.setCornerRadius(tag.radius);
289 if (tag.layoutBorderSize > 0) {
290 gdNormal.setStroke(Utils.dipToPx(getContext(), tag.layoutBorderSize), tag.layoutBorderColor);
291 }
292 GradientDrawable gdPress = new GradientDrawable();
293 gdPress.setColor(tag.layoutColorPress);
294 gdPress.setCornerRadius(tag.radius);
295 states.addState(new int[]{android.R.attr.state_pressed}, gdPress);
296 //must add state_pressed first,or state_pressed will not take effect
297 states.addState(new int[]{}, gdNormal);
298 return states;
299 }
300
301
302 //public methods

Callers 1

drawTagsMethod · 0.95

Calls 2

dipToPxMethod · 0.95
setColorMethod · 0.80

Tested by

no test coverage detected