像html一样显示android TextViews浮动div

发布于 2024-09-27 10:41:33 字数 425 浏览 0 评论 0原文

我在RelativeLayout 容器中有三个TextView 元素:
@+id/name、@+id/message、@+id/time

@+id/message 通过布局定位在 @+id/name 的右侧,@+id/time 位于 @+id/ 的右侧信息。只要这三个元素不占据屏幕的宽度,它就会呈现良好的效果,但是当它占据屏幕的宽度时,它会弹起最后一个元素。

如果发生这种情况,我希望它在下面溢出。我能想到的最好的方法是有 3 个 html div

<div style='float:left;'>name</div>
<div style='float:left'>message</div>
<div style='float:left;'>time</div>

I have three TextView elements within a RelativeLayout container:
@+id/name, @+id/message, @+id/time

The @+id/message is positioned by layout to right of @+id/name and @+id/time is to the right of @+id/message. It renders fine as long as the three elements don't take up the width of the screen, but when it does, it bounces up the last element.

I want it to overflow below if this happenens. The best way I can think of it would be having 3 html divs

<div style='float:left;'>name</div>
<div style='float:left'>message</div>
<div style='float:left;'>time</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愛上了 2024-10-04 10:41:33

自定义 FlowLayout 类可用于在一行中显示子级,然后如果没有足够的空间则开始新行:
https://github.com/triposo/barone /blob/master/src/com/triposo/barone/FlowLayout.java

The custom FlowLayout class can be used to display the children in a line and then if there is not enough space start a new line:
https://github.com/triposo/barone/blob/master/src/com/triposo/barone/FlowLayout.java

雾里花 2024-10-04 10:41:33

也许您可以尝试获取屏幕尺寸,然后根据屏幕尺寸动态创建这些元素?

Maybe you could try getting the screen size and then dynamically creating these elements depending on the screen size?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文