textview gets the width and whether the text width is wrapped

//Get the width of the text 
var spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); 
tv_textcontent.measure(spec, spec); 
var textPaint = tv_textcontent.getPaint(); 
var textPaintWidth = textPaint.measureText( str);
var textwidth=px2dp(mContext, tv_textcontent.width.toFloat())//text control width 
var mwidth=px2dp(mContext, textPaintWidth)//string text required width

//When textwidth is greater than mwidth, one line can be displayed, otherwise a line break is required.

Guess you like

Origin blog.csdn.net/qq_25462179/article/details/125377317