什么是过时的StaticLayout的替代品 [英] What is the substitute for deprecated StaticLayout

查看:671
本文介绍了什么是过时的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆