Skip to content

Commit

Permalink
Update onDraw translate computation to align with text better.
Browse files Browse the repository at this point in the history
  • Loading branch information
markzhai committed Sep 6, 2015
1 parent 61647ba commit 86af6b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ styles:
- Add more hint mode.
- Enable pair mode, like username/password.
- Center gravity is not supported yet, need help (icon is missing when set center gravity).
- Add encrpytion mode to save stuff like password (low priority).
- Add encrpytion mode to save stuff like password (low priority).
- Support RTL (Right to Left).
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,19 @@ private void initData() {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.translate(getMeasuredWidth() - mDropDownDrawable.getIntrinsicWidth()
- mDeleteDrawable.getIntrinsicWidth() - ICON_MARGIN, getPaddingTop());

final int compoundPaddingTop = getCompoundPaddingTop();
final int compoundPaddingBottom = getCompoundPaddingBottom();

int vspace = getBottom() - getTop() - compoundPaddingBottom - compoundPaddingTop;
int drawableHeight = mDeleteDrawable.getIntrinsicHeight();
int dropDownWidth = mDropDownDrawable.getIntrinsicWidth();
int deleteWidth = mDeleteDrawable.getIntrinsicWidth();

canvas.translate(getMeasuredWidth() - getCompoundPaddingRight() - dropDownWidth - ICON_MARGIN - deleteWidth,
getCompoundPaddingTop() + getScrollY() + (vspace - drawableHeight) / 2);
mDeleteDrawable.draw(canvas);
canvas.translate(mDeleteDrawable.getIntrinsicWidth() + ICON_MARGIN, 0);
canvas.translate(deleteWidth + ICON_MARGIN, 0);
mDropDownDrawable.draw(canvas);
canvas.restore();
}
Expand Down

0 comments on commit 86af6b1

Please sign in to comment.