我想写一个日历应用程序,我打算有一个网格(周视图),这可能会是一个 TableLayout
并直接最重要的是,我将有到网格上绝对位置的事件。
I am trying to write a calendar app and I plan to have a grid (week view) which will probably be a TableLayout
and directly on top of that I will have to absolutely position events on the grid.
但 AbsoluteLayout
是德precated。我应该用什么代替呢?
But AbsoluteLayout
is deprecated. What should I use instead?
事件可能会重叠,我认为这将是非常愚蠢的尝试和使用非绝对布局,以达到我想要的。
Events may overlap and I think it would be really silly to try and use a non absolute layout to achieve what I want.
也许我应该用 RelativeLayout的
对每个子节点的保证金左,保证金顶部。似乎很奇怪,这样做的,可能不会被视为有效。这是最好的方法还是有别的选择吗?
Maybe I should use RelativeLayout
with a margin left and margin top on each of the child nodes. Seems odd to do it that way and might not be as efficient. Is this the best way or is there an alternative?
我发现可以通过添加您的孩子的观点到 RelativeLayout的
重新绝对定位并设置 RelativeLayout.LayoutParams
仅具有默认值除外的宽度,高度,和marginTop marginLeft。顶部和左边缘将类似于顶部和左侧的 AbsoluteLayout
。此外,切缘阴性的支持。
I found out you can recreate absolute positioning by adding your child views to a RelativeLayout
and set the RelativeLayout.LayoutParams
to have only default values except width, height, marginTop and marginLeft. The top and left margin will be similar to top and left in AbsoluteLayout
. Also, negative margins are supported.
请确保你考虑屏幕像素密度和宽度方向的变化和绝对定位的所有其他注意事项所使用适用于 AbsoluteLayout
Make sure you account for screen density and width and orientation changes and all the other caveats of absolute positioning that used to apply to AbsoluteLayout
如果您有问题,让您的内容溢出经过屏幕的右边缘,尝试用一个同样的负面右边距补充你的积极左边距。 (original问题)
If you have problems with getting your content to overflow past the right edge of the screen, try supplementing your positive left margin with an equally negative right margin. (original question)