应该使用什么而不是:
StaticLayout layout = new StaticLayout(text, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false);发出此警告:
警告:反对StaticLayout(CharSequence,TextPaint,int,对齐,浮点数,浮点数,布尔值)在StaticLayout中已被弃用的StaticLayout layout =新StaticLayout(文本、油漆、宽度、Alignment.ALIGN_NORMAL、mSpacingMult、mSpacingAdd、false);
发布于 2018-11-01 16:52:50
使用StaticLayout.Builder。要获得更多详细信息,请在这里查看:https://developer.android.com/reference/android/text/StaticLayout.Builder
对于您的案例使用:
StaticLayout.Builder sb = StaticLayout.Builder.obtain(text, 0, text.length(), paint, width)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setLineSpacing(mSpacingAdd, mSpacingMult)
.setIncludePad (false);
StaticLayout layout = sb.build();https://stackoverflow.com/questions/53105715
复制相似问题