开发者

In a RelativeLayout how to prevent objects from piling up on eachother?

I'm starting to use RelativeLayout more and more but there are some things I keep running into.

Say I have a status textview that I want top and center. Then I have a bunch of other objects below it like images and a table layout.

I want the stuff below the status text view to respect the status textview's personal space and not draw themselves ri开发者_JAVA技巧ght on top of it.

But what I'm seeing is that in a relativelayout, everything piles up on eachother unless I use alignment such as android:layout_below and android:layout_above.

Is there an attribute that I can add to the status textview to make it so other objects don't want to draw right on top of it? Or do I have to keep using the alignment tags on everything and align things away from it?

Thanks!


As described by the docs:

RelativeLayout is a Layout where the positions of the children can be described in relation to each other or to the parent

So you need to give an indication of how each UI element is to be positionned either with respect to one another or to the parent. Depending on your needs, you may be able to just use android:layout_alignWithParentIfMissing="true". Based on your description, I don't think you can do so.

See RelativeLayout Parameters. .

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜