@@ -18,8 +18,13 @@ public class ButtonFlat extends Button {
18
18
19
19
public ButtonFlat (Context context , AttributeSet attrs ) {
20
20
super (context , attrs );
21
-
22
21
}
22
+
23
+ public void setTextColor (int color ) {
24
+ if (null != textButton ) {
25
+ textButton .setTextColor (color );
26
+ }
27
+ }
23
28
24
29
protected void setDefaultProperties (){
25
30
minHeight = 36 ;
@@ -44,16 +49,18 @@ protected void setAttributes(AttributeSet attrs) {
44
49
if (text != null ){
45
50
textButton = new TextView (getContext ());
46
51
textButton .setText (text .toUpperCase ());
47
- textButton .setTextColor (backgroundColor );
52
+ textButton .setTextColor (this . backgroundColor );
48
53
textButton .setTypeface (null , Typeface .BOLD );
49
54
RelativeLayout .LayoutParams params = new RelativeLayout .LayoutParams (LayoutParams .WRAP_CONTENT ,LayoutParams .WRAP_CONTENT );
50
55
params .addRule (RelativeLayout .CENTER_IN_PARENT , RelativeLayout .TRUE );
51
56
textButton .setLayoutParams (params );
52
57
addView (textButton );
53
58
}
54
- int bacgroundColor = attrs .getAttributeResourceValue (ANDROIDXML ,"background" ,-1 );
55
- if (bacgroundColor != -1 ){
56
- setBackgroundColor (getResources ().getColor (bacgroundColor ));
59
+
60
+ int backgroundColor = attrs .getAttributeResourceValue (ANDROIDXML ,"background" ,-1 );
61
+
62
+ if (backgroundColor != -1 ){
63
+ setBackgroundColor (getResources ().getColor (backgroundColor ));
57
64
}else {
58
65
// Color by hexadecimal
59
66
// Color by hexadecimal
@@ -62,8 +69,7 @@ protected void setAttributes(AttributeSet attrs) {
62
69
setBackgroundColor (background );
63
70
}
64
71
}
65
-
66
-
72
+
67
73
@ Override
68
74
protected void onDraw (Canvas canvas ) {
69
75
super .onDraw (canvas );
@@ -116,5 +122,4 @@ public TextView getTextView() {
116
122
public String getText (){
117
123
return textButton .getText ().toString ();
118
124
}
119
-
120
125
}
0 commit comments