Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ public class LetterImageView extends ImageView {
private Paint mBackgroundPaint;
private int mTextColor = Color.WHITE;
private boolean isOval;
private Rect textBounds;

public LetterImageView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}

private void init() {

textBounds = new Rect();
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setColor(mTextColor);
mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
Expand Down Expand Up @@ -71,8 +74,7 @@ protected void onDraw(Canvas canvas) {
} else {
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint);
}
// Measure a text
Rect textBounds = new Rect();

mTextPaint.getTextBounds(String.valueOf(mLetter), 0, 1, textBounds);
float textWidth = mTextPaint.measureText(String.valueOf(mLetter));
float textHeight = textBounds.height();
Expand Down