开发者

Display android TextViews like html would floating divs

开发者 https://www.devze.com 2023-01-19 22:52 出处:网络
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 @+

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>


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消