Skip to content

Commit

Permalink
移除label默认宽高
Browse files Browse the repository at this point in the history
  • Loading branch information
JinJieGu committed Feb 5, 2018
1 parent 73e4ded commit ac5e2df
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public int getSize(Paint paint, CharSequence text, int start, int end, Paint.Fon

@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
float finalUnitHeight = bottom - top;
float finalUnitHeight = 2*bottom - top;
float bgTop = bottom - finalUnitHeight;
if (isClickable && isSelected && pressBgColor != 0) {
// click background
Expand Down Expand Up @@ -216,11 +216,13 @@ private float initFinalWidth(Paint paint) {

int labelBgWidth = mSpecialLabelUnit.getLabelBgWidth();
mSpecialTextWidth = paint.measureText(mSpecialText, 0, mSpecialText.length());
if (labelBgWidth > 0 && labelBgWidth > mSpecialTextWidth) {
mFinalWidth = labelBgWidth;
} else {
mFinalWidth = mSpecialTextWidth + mPaddingLeft + mPaddingRight;
}
// if (labelBgWidth > 0 && labelBgWidth > mSpecialTextWidth) {
// mFinalWidth = labelBgWidth;
// } else {
// mFinalWidth = mSpecialTextWidth + mPaddingLeft + mPaddingRight;
// }

mFinalWidth = labelBgWidth;
}

return mFinalWidth;
Expand All @@ -244,12 +246,12 @@ private float initFinalHeight(Paint paint) {
mSpecialTextHeight = specialTextRect.height();
mSpecialTextBaselineOffset = specialTextRect.bottom;

if (labelBgHeight > 0 && labelBgHeight > mSpecialTextHeight && labelBgHeight <= mLineTextHeight) {
mFinalHeight = labelBgHeight;
} else {
mFinalHeight = mSpecialTextHeight + mPaddingTop + mPaddingBottom;
}

// if (labelBgHeight > 0 && labelBgHeight > mSpecialTextHeight && labelBgHeight <= mLineTextHeight) {
// mFinalHeight = labelBgHeight;
// } else {
// mFinalHeight = mSpecialTextHeight + mPaddingTop + mPaddingBottom;
// }
mFinalHeight = labelBgHeight;
if (mFinalHeight > mLineTextHeight) {
mFinalHeight = mLineTextHeight;
}
Expand Down

0 comments on commit ac5e2df

Please sign in to comment.