Skip to content

Commit

Permalink
support dash
Browse files Browse the repository at this point in the history
  • Loading branch information
hoanganhtuan95ptit committed Dec 12, 2024
1 parent 287c7a2 commit c741501
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class RoundViewDelegate {

private int strokeWidth;
private int strokeColor;
private int strokeDashGap;
private int strokeDashWidth;
private int strokePressColor;
private int textPressColor;

Expand All @@ -55,6 +57,9 @@ private void obtainAttributes(Context context, AttributeSet attrs) {
cornerRadius = ta.getDimensionPixelSize(R.styleable.RoundView_rv_cornerRadius, 0);
strokeWidth = ta.getDimensionPixelSize(R.styleable.RoundView_rv_strokeWidth, 0);
strokeColor = ta.getColor(R.styleable.RoundView_rv_strokeColor, Color.TRANSPARENT);
strokeDashGap = ta.getDimensionPixelSize(R.styleable.RoundView_rv_strokeDashGap, 0);
strokeDashWidth = ta.getDimensionPixelSize(R.styleable.RoundView_rv_strokeDashWidth, 0);
strokePressColor = ta.getColor(R.styleable.RoundView_rv_strokePressColor, Integer.MAX_VALUE);
strokePressColor = ta.getColor(R.styleable.RoundView_rv_strokePressColor, Integer.MAX_VALUE);
textPressColor = ta.getColor(R.styleable.RoundView_rv_textPressColor, Integer.MAX_VALUE);
isRadiusHalfHeight = ta.getBoolean(R.styleable.RoundView_rv_isRadiusHalfHeight, false);
Expand Down Expand Up @@ -213,7 +218,7 @@ private void setDrawable(GradientDrawable gd, int color, int strokeColor) {
gd.setCornerRadius(cornerRadius);
}

gd.setStroke(strokeWidth, strokeColor);
gd.setStroke(strokeWidth, strokeColor, strokeDashWidth, strokeDashGap);
}

public void setBgSelector() {
Expand Down
41 changes: 23 additions & 18 deletions core/android/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@
<attr name="rv_backgroundColor" format="color" />
<attr name="rv_backgroundPressColor" format="color" />
<attr name="rv_cornerRadius" format="dimension" />
<attr name="rv_strokeWidth" format="dimension" />
<attr name="rv_strokeColor" format="color" />
<attr name="rv_strokeWidth" format="dimension" />
<attr name="rv_strokeDashGap" format="dimension" />
<attr name="rv_strokeDashWidth" format="dimension" />
<attr name="rv_strokePressColor" format="color" />
<attr name="rv_textPressColor" format="color" />
<attr name="rv_isRadiusHalfHeight" format="boolean" />
Expand All @@ -95,23 +97,8 @@
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
<attr name="rv_isWidthHeightEqual" />
<attr name="rv_cornerRadius_TL" />
<attr name="rv_cornerRadius_TR" />
<attr name="rv_cornerRadius_BL" />
<attr name="rv_cornerRadius_BR" />
<attr name="rv_isRippleEnable" />
</declare-styleable>

<declare-styleable name="RoundTextView">
<attr name="rv_backgroundColor" />
<attr name="rv_backgroundPressColor" />
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokeDashGap" />
<attr name="rv_strokeDashWidth" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
Expand All @@ -129,7 +116,10 @@
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokeDashGap" />
<attr name="rv_strokeDashWidth" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
<attr name="rv_isWidthHeightEqual" />
<attr name="rv_cornerRadius_TL" />
Expand All @@ -145,7 +135,10 @@
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokeDashGap" />
<attr name="rv_strokeDashWidth" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
<attr name="rv_isWidthHeightEqual" />
<attr name="rv_cornerRadius_TL" />
Expand All @@ -161,7 +154,10 @@
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokeDashGap" />
<attr name="rv_strokeDashWidth" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
<attr name="rv_isWidthHeightEqual" />
<attr name="rv_cornerRadius_TL" />
Expand All @@ -177,7 +173,10 @@
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokeDashGap" />
<attr name="rv_strokeDashWidth" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
<attr name="rv_isWidthHeightEqual" />
<attr name="rv_cornerRadius_TL" />
Expand All @@ -193,7 +192,10 @@
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokeDashGap" />
<attr name="rv_strokeDashWidth" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
<attr name="rv_isWidthHeightEqual" />
<attr name="rv_cornerRadius_TL" />
Expand All @@ -209,7 +211,10 @@
<attr name="rv_cornerRadius" />
<attr name="rv_strokeWidth" />
<attr name="rv_strokeColor" />
<attr name="rv_strokeDashGap" />
<attr name="rv_strokeDashWidth" />
<attr name="rv_strokePressColor" />
<attr name="rv_textPressColor" />
<attr name="rv_isRadiusHalfHeight" />
<attr name="rv_isWidthHeightEqual" />
<attr name="rv_cornerRadius_TL" />
Expand Down

0 comments on commit c741501

Please sign in to comment.