init name plate bg drawable width
This commit is contained in:
@@ -75,6 +75,17 @@ public class CustomImageSpan extends ImageSpan {
|
||||
this.url = url;
|
||||
this.reference = new WeakReference<>(textView);
|
||||
this.height = SizeUtils.dp2px(textView.getContext(), 17);
|
||||
|
||||
// width 不初始化会导致后面布局被截断
|
||||
// 暂时先初始化为设计稿宽度
|
||||
// 不是一个很好的处理办法,可以优化
|
||||
final float ORI_HEIGHT = 34; // 原设计稿高度34px
|
||||
float ratio = height / ORI_HEIGHT;
|
||||
Paint paint = new Paint();
|
||||
paint.setTextSize(ratio * 18);
|
||||
float textWidth = paint.measureText(content);
|
||||
this.width = (int) (textWidth + (40 + 4) * ratio + 16 * ratio);
|
||||
|
||||
this.drawable = defaultDrawable;
|
||||
getDrawable().setBounds(0, 0, width, height);
|
||||
loadPicAsyncWithHeight();
|
||||
|
Reference in New Issue
Block a user