像html一样显示android TextViews浮动div
我在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自定义 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
也许您可以尝试获取屏幕尺寸,然后根据屏幕尺寸动态创建这些元素?
Maybe you could try getting the screen size and then dynamically creating these elements depending on the screen size?