Skip to content

Commit

Permalink
1,修改测量宽度
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Oct 20, 2023
1 parent ff7383e commit 0ff3efe
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,14 @@ static CharSequence createIndentedText(CharSequence text, int marginFirstLine, i

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
if (widthMode == MeasureSpec.AT_MOST && strokeWidth > 0){
int measureWidth = getMeasuredWidth();
int width = MeasureSpec.getSize(widthMeasureSpec);
if (measureWidth < width){
int measureHeight = getMeasuredHeight();
// int height = MeasureSpec.getSize(heightMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int newWidth = MeasureSpec.makeMeasureSpec(measureWidth+Math.min(strokeWidth/2,width-measureWidth), widthMode);
setMeasuredDimension(newWidth,MeasureSpec.makeMeasureSpec(measureHeight, heightMode));
setMeasuredDimension(measureWidth+Math.min(strokeWidth/2,width-measureWidth),measureHeight);
}
}
}
Expand Down

0 comments on commit 0ff3efe

Please sign in to comment.