Last active
September 1, 2016 05:16
-
-
Save noaht11/a38559cf96c1c81af188ef972eb9b2c8 to your computer and use it in GitHub Desktop.
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
@Override | |
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { | |
// Shift everything mLeftMarginPx to the left to create an empty space on the left (creating the margin) | |
x += mLeftMarginPx; | |
if (mChipHeight != -1) { | |
// If we set a chip height, adjust to vertically center chip in the line | |
// Adding (bottom - top) / 2 shifts the chip down so the top of it will be centered vertically | |
// Subtracting (mChipHeight / 2) shifts the chip back up so that the center of it will be centered vertically (as desired) | |
top += ((bottom - top) / 2) - (mChipHeight / 2); | |
bottom = top + mChipHeight; | |
} | |
// Perform actual drawing | |
drawBackground(canvas, x, top, bottom, paint); | |
drawText(canvas, x, top, bottom, paint, mTextToDraw); | |
if (mIcon != null) { | |
drawIcon(canvas, x, top, bottom, paint); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment