Created
November 9, 2018 16:28
-
-
Save raghunandankavi2010/3399c08591ef8104a627bd3aefadef07 to your computer and use it in GitHub Desktop.
labels without rounded rect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void drawLabels(Canvas canvas) { | |
weekWidth = (getWidth () - getPaddingLeft () - getPaddingRight ()) / weeksCount; | |
graphHeight = getHeight () - getPaddingTop () - getPaddingBottom (); | |
float centerX = getPaddingLeft() + (weekWidth/2); | |
for(int i=0;i<weeksCount;i++) { | |
String week = "week "+i; | |
mTextPaint.getTextBounds(week, 0, week.length(), textBounds); | |
int mTextWidth = Math.round(mTextPaint.measureText(week)); // Use measureText to calculate width | |
int mTextHeight = textBounds.height(); // Use height from getTextBounds() | |
canvas.drawText(week, centerX - (mTextWidth / 2), (getHeight() - getPaddingBottom()) + 100, mTextPaint);//100 hardcoded | |
centerX = centerX+ (weekWidth); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment