Skip to content

Commit

Permalink
add setText method
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven committed Feb 27, 2017
1 parent a4e4cfd commit 068d326
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/java/com/dx/dxloadingbutton/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void onClick(View view) {
lb.startLoading();
}
});

sucBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -299,6 +300,18 @@ public void setTypeface(Typeface typeface){
}
}

public void setText(String text){
if(TextUtils.isEmpty(text)){
return;
}
this.mText = text;
mTextWidth = mTextPaint.measureText(mText);
Rect bounds = new Rect();
mTextPaint.getTextBounds(mText,0,mText.length(),bounds);
mTextHeight = bounds.height();
invalidate();
}


public void setResetAfterFailed(boolean resetAfterFailed){
this.resetAfterFailed = resetAfterFailed;
Expand Down

0 comments on commit 068d326

Please sign in to comment.