Skip to content

Commit df7ba59

Browse files
committed
Update ButtonFlat.java
1 parent 1dd356a commit df7ba59

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

MaterialDesign/src/com/gc/materialdesign/views/ButtonFlat.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ public class ButtonFlat extends Button {
1818

1919
public ButtonFlat(Context context, AttributeSet attrs) {
2020
super(context, attrs);
21-
2221
}
22+
23+
public void setTextColor(int color) {
24+
if (null != textButton) {
25+
textButton.setTextColor(color);
26+
}
27+
}
2328

2429
protected void setDefaultProperties(){
2530
minHeight = 36;
@@ -44,16 +49,18 @@ protected void setAttributes(AttributeSet attrs) {
4449
if(text != null){
4550
textButton = new TextView(getContext());
4651
textButton.setText(text.toUpperCase());
47-
textButton.setTextColor(backgroundColor);
52+
textButton.setTextColor(this.backgroundColor);
4853
textButton.setTypeface(null, Typeface.BOLD);
4954
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
5055
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
5156
textButton.setLayoutParams(params);
5257
addView(textButton);
5358
}
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));
5764
}else{
5865
// Color by hexadecimal
5966
// Color by hexadecimal
@@ -62,8 +69,7 @@ protected void setAttributes(AttributeSet attrs) {
6269
setBackgroundColor(background);
6370
}
6471
}
65-
66-
72+
6773
@Override
6874
protected void onDraw(Canvas canvas) {
6975
super.onDraw(canvas);
@@ -116,5 +122,4 @@ public TextView getTextView() {
116122
public String getText(){
117123
return textButton.getText().toString();
118124
}
119-
120125
}

0 commit comments

Comments
 (0)