gpt4 book ai didi

java - 是否可以将两条线视为一条线?

转载 作者:行者123 更新时间:2023-12-01 09:28:20 24 4
gpt4 key购买 nike

线路:

 This is the first line and it is long line1.
This is the second line and it is long line2.

显然,这两行末尾都包含“\n”。

但是当设备屏幕很小时,在某些时候。

默认输出:

  This is the first line and
it is long line1.
This is the second line and
it is long line2.

预期输出:

  This is the first line and
This is the second line and
it is long line1.
it is long line2.

除了使用 ReplacementSpan 在第二行上方绘制第一行之外,作为一种解决方法,我想知道是否可以将这两行视为一条线。我必须采取哪些选择才能实现这样的输出?

最佳答案

“逻辑”解决方案是将第一个换行符 \n 替换为空格。

但就您而言,您似乎想要水平滚动的 TextView :

<TextView 
android:lines="2"
android:scrollHorizontally="true"
android:singleLine="true" ... />

我不确定 linessingleLine 属性。

关于java - 是否可以将两条线视为一条线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39659587/

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