File tree Expand file tree Collapse file tree 8 files changed +56
-2
lines changed
AndroidStudio/MaterialDesign/app/src/main
java/com/gc/materialdesign/views
src/com/gc/materialdesign/views Expand file tree Collapse file tree 8 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ protected void setDefaultProperties(){
33
33
super .minHeight = 36 ;
34
34
super .background = R .drawable .background_button_rectangle ;
35
35
super .setDefaultProperties ();
36
- rippleSpeed = Utils .dpToPx (3 , getResources ());
37
36
}
38
37
39
38
@@ -97,6 +96,9 @@ protected void setAttributes(AttributeSet attrs){
97
96
// textView.setLayoutParams(params);
98
97
99
98
}
99
+
100
+ rippleSpeed = attrs .getAttributeFloatValue (MATERIALDESIGNXML ,
101
+ "rippleSpeed" , Utils .dpToPx (6 , getResources ()));
100
102
}
101
103
102
104
// /**
Original file line number Diff line number Diff line change @@ -154,6 +154,9 @@ public void setBackgroundColor(int color) {
154
154
155
155
public void setChecked (boolean check ) {
156
156
this .check = check ;
157
+ setPressed (false );
158
+ changeBackgroundColor (getResources ().getColor (
159
+ android .R .color .transparent ));
157
160
if (check ) {
158
161
step = 0 ;
159
162
}
Original file line number Diff line number Diff line change @@ -46,6 +46,24 @@ protected void setAttributes(AttributeSet attrs) {
46
46
else
47
47
setBackgroundColor (this .backgroundColor );
48
48
}
49
+ // Set background Color
50
+ // Color by resource
51
+ int rippleColor = attrs .getAttributeResourceValue (MATERIALDESIGNXML ,
52
+ "rippleColor" , -1 );
53
+ if (rippleColor != -1 ) {
54
+ setRippleColor (getResources ().getColor (rippleColor ));
55
+ } else {
56
+ // Color by hexadecimal
57
+ String background = attrs .getAttributeValue (MATERIALDESIGNXML ,
58
+ "rippleColor" );
59
+ if (background != null )
60
+ setRippleColor (Color .parseColor (background ));
61
+ else
62
+ setRippleColor (makePressColor ());
63
+ }
64
+
65
+ rippleSpeed = attrs .getAttributeFloatValue (MATERIALDESIGNXML ,
66
+ "rippleSpeed" , 20f );
49
67
}
50
68
51
69
// Set color of background
Original file line number Diff line number Diff line change 17
17
<attr name =" iconFloat" format =" integer" />
18
18
<!-- in float button indicate if must start with animation -->
19
19
<attr name =" animate" format =" boolean" />
20
+ <!-- Speed of ripple animation -->
21
+ <attr name =" rippleSpeed" format =" float" />
22
+ <!-- in float button indicate if must start with animation -->
23
+ <attr name =" rippleColor" format =" color|reference" />
20
24
</declare-styleable >
21
25
22
26
Original file line number Diff line number Diff line change 17
17
<attr name =" iconFloat" format =" integer" />
18
18
<!-- in float button indicate if must start with animation -->
19
19
<attr name =" animate" format =" boolean" />
20
+ <!-- Speed of ripple animation -->
21
+ <attr name =" rippleSpeed" format =" float" />
22
+ <!-- in float button indicate if must start with animation -->
23
+ <attr name =" rippleColor" format =" color|reference" />
20
24
</declare-styleable >
21
25
22
26
Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ protected void setDefaultProperties(){
33
33
super .minHeight = 36 ;
34
34
super .background = R .drawable .background_button_rectangle ;
35
35
super .setDefaultProperties ();
36
- rippleSpeed = Utils .dpToPx (3 , getResources ());
37
36
}
38
37
39
38
@@ -97,6 +96,9 @@ protected void setAttributes(AttributeSet attrs){
97
96
// textView.setLayoutParams(params);
98
97
99
98
}
99
+
100
+ rippleSpeed = attrs .getAttributeFloatValue (MATERIALDESIGNXML ,
101
+ "rippleSpeed" , Utils .dpToPx (6 , getResources ()));
100
102
}
101
103
102
104
// /**
Original file line number Diff line number Diff line change @@ -154,6 +154,9 @@ public void setBackgroundColor(int color) {
154
154
155
155
public void setChecked (boolean check ) {
156
156
this .check = check ;
157
+ setPressed (false );
158
+ changeBackgroundColor (getResources ().getColor (
159
+ android .R .color .transparent ));
157
160
if (check ) {
158
161
step = 0 ;
159
162
}
Original file line number Diff line number Diff line change @@ -46,6 +46,24 @@ protected void setAttributes(AttributeSet attrs) {
46
46
else
47
47
setBackgroundColor (this .backgroundColor );
48
48
}
49
+ // Set background Color
50
+ // Color by resource
51
+ int rippleColor = attrs .getAttributeResourceValue (MATERIALDESIGNXML ,
52
+ "rippleColor" , -1 );
53
+ if (rippleColor != -1 ) {
54
+ setRippleColor (getResources ().getColor (rippleColor ));
55
+ } else {
56
+ // Color by hexadecimal
57
+ String background = attrs .getAttributeValue (MATERIALDESIGNXML ,
58
+ "rippleColor" );
59
+ if (background != null )
60
+ setRippleColor (Color .parseColor (background ));
61
+ else
62
+ setRippleColor (makePressColor ());
63
+ }
64
+
65
+ rippleSpeed = attrs .getAttributeFloatValue (MATERIALDESIGNXML ,
66
+ "rippleSpeed" , 20f );
49
67
}
50
68
51
69
// Set color of background
You can’t perform that action at this time.
0 commit comments