什么是过时的StaticLayout的替代品 [英] What is the substitute for deprecated StaticLayout
问题描述
应使用什么代替:
StaticLayout layout = new StaticLayout(text, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false);
给出此警告:
警告:[弃用] StaticLayout(CharSequence,TextPaint,int,Alignment,float,float,boolean) 在StaticLayout中已弃用 StaticLayout layout = new StaticLayout(text,paint,width,Alignment.ALIGN_NORMAL,mSpacingMult,mSpacingAdd,false);
warning: [deprecation] StaticLayout(CharSequence,TextPaint,int,Alignment,float,float,boolean) in StaticLayout has been deprecated StaticLayout layout = new StaticLayout(text, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false);
推荐答案
使用StaticLayout.Builder
.
在此处查看更多详细信息: https://developer.android.com/reference/android/text/StaticLayout.Builder
Use StaticLayout.Builder
.
Go through here for more details: https://developer.android.com/reference/android/text/StaticLayout.Builder
供您使用:
StaticLayout.Builder sb = StaticLayout.Builder.obtain(text, paint, width)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setLineSpacing(mSpacingAdd, mSpacingMult)
.setIncludePad (false);
StaticLayout layout = sb.build();
这篇关于什么是过时的StaticLayout的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!