程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了应用 lineHeight 或 lineSpacingExtra 不起作用大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决应用 lineHeight 或 linespacingExtra 不起作用?

开发过程中遇到应用 lineHeight 或 linespacingExtra 不起作用的问题如何解决?下面主要结合日常开发的经验,给出你关于应用 lineHeight 或 linespacingExtra 不起作用的解决方法建议,希望对你解决应用 lineHeight 或 linespacingExtra 不起作用有所启发或帮助;

我有简单的 xml 布局,上面有 comments

TextVIEw

应用 lineHeight 或 lineSpacingExtra 不起作用

我正在尝试将 <TextVIEw androID:ID="@+ID/textVIEw9" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="TextVIEw1" app:layout_consTraintBottom_toBottomOf="parent" app:layout_consTraintEnd_toEndOf="parent" app:layout_consTraintStart_toStartOf="parent" app:layout_consTrainttop_totopOf="parent" /> <TextVIEw androID:ID="@+ID/textVIEw10" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="TextVIEw2" app:layout_consTraintEnd_toEndOf="parent" app:layout_consTraintStart_toStartOf="parent" app:layout_consTrainttop_toBottomOf="@+ID/textVIEw9" /> 属性应用于第二个 linespacingExtra。它没有任何效果。与 TextVIEw 相同。

我对这些属性如何工作的理解有误吗?

lineHeight

应用 lineHeight 或 lineSpacingExtra 不起作用

解决方法

来自docs:

该值不会应用于最后一行文本。

因此,如果您将多行文本添加到 TextView(例如:TextView1\ntextView2),它将起作用。

,

使用多行。 使用“dp”代替“sp”:

android:linespacingExtra="20dp"

大佬总结

以上是大佬教程为你收集整理的应用 lineHeight 或 lineSpacingExtra 不起作用全部内容,希望文章能够帮你解决应用 lineHeight 或 lineSpacingExtra 不起作用所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。