gpt4 book ai didi

android - 什么是已弃用的 StaticLayout 的替代品

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:17:18 29 4
gpt4 key购买 nike

应该用什么代替:

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

为您的案例使用:

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();

关于android - 什么是已弃用的 StaticLayout 的替代品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53105715/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com