1

the question "What is a usefull alternative to AbsoluteLayout?" seems to be a question which is often asked, but never really answered. My situation is as follows:

I want to position Circles (for the sake of simplicity i used RadioButtons for testing) so that the distances between the circles are proportional on all possible display sizes.

Also i need to know the position of the circles to match onTouchEvent.

This seems fairly easy with AbsoluteLayout since i can get (at runtime) the defaultDisplay's width and height and so i can position Objects in an AbsoluteLayout relative to the display metrics.

Now I want to avoid AbsoluteLayout for obvious reasons, but RelativeLayout doesn't seem to be an alternative since - as far as i know - one can only say "put that object right next to that other object" or below or whatever. How to fix this?

4

2 回答 2

2

在我看来,实现目标的最佳方式是使用画布并自己绘制所有内容。在 Canvas 中,您拥有运行时屏幕的信息,并且您可以完全控制要绘制的内容。

于 2011-10-08T11:44:57.570 回答
0

如果您只需要绘制自己的形状(并处理所有正常的触摸事件)并且不需要同一视图上的其他 UI Widget,那么使用Canvas.

如果您确实需要此视图上的小部件,那么您唯一的选择是AbsoluteLayout.

于 2011-10-08T12:51:00.543 回答