I have an activity with a grid of 3x4 Button. See the image below. When the user touches one of the buttons the button is animated.
我有一个3x4 Button网格的活动。见下图。当用户触摸其中一个按钮时,该按钮被动画化。
The button moves from its current location to the center of the screen holds and then returns to its original position. While its doing this the button is also growing to fill the screen, holds and then shrinks back down to its original size.
按钮从其当前位置移动到屏幕中心,然后返回其原始位置。在这样做的同时,按钮也在增长以填充屏幕,保持然后缩小回原始尺寸。
During the animation no other buttons should move.
在动画期间,没有其他按钮应该移动。
Originally I coded this up using an AbsoluteLayout, however, as this layout is deprecated I'd like to use a different layout, but I'm not sure which one to use.
最初我使用AbsoluteLayout编写了这个,但是,由于这个布局已被弃用,我想使用不同的布局,但我不确定使用哪个布局。
Is there a better way to layout this activity while still allowing me to achieve the described behavior, and if so what layout should I use and how should I structure it?
有没有更好的方法来布局这个活动,同时仍然允许我实现所描述的行为,如果是这样,我应该使用什么布局,我应该如何构建它?
3 个解决方案
#1
1
use a gridlayout, that seems to make the most sense from what your picture looks like.
使用gridlayout,这似乎是你的图片看起来最有意义的。
#2
0
I would use a RelativeLayout but without aligning the buttons to each other with above/below/leftOf/rightOf.
我会使用RelativeLayout,但没有使用above / below / leftOf / rightOf将按钮彼此对齐。
By the way, isn't this question related to your other question: Android Animation leaves lines during movement
顺便说一下,这个问题不是与你的另一个问题有关:Android动画在移动过程中会留下线条
Anyway, as I already said I would use a RelativeLayout, place the buttons as required by setting their marginLeft/marginTop values accordingly. This leaves the buttons independent of each other.
无论如何,正如我已经说过的,我将使用RelativeLayout,通过相应地设置marginLeft / marginTop值来根据需要放置按钮。这使按钮彼此独立。
Then in your animation code change the margin and dimension values of the current button as required.
然后在动画代码中根据需要更改当前按钮的边距和尺寸值。
#3
0
In the end I decided to go with the AbsoluteLayout
最后我决定选择AbsoluteLayout
#1
1
use a gridlayout, that seems to make the most sense from what your picture looks like.
使用gridlayout,这似乎是你的图片看起来最有意义的。
#2
0
I would use a RelativeLayout but without aligning the buttons to each other with above/below/leftOf/rightOf.
我会使用RelativeLayout,但没有使用above / below / leftOf / rightOf将按钮彼此对齐。
By the way, isn't this question related to your other question: Android Animation leaves lines during movement
顺便说一下,这个问题不是与你的另一个问题有关:Android动画在移动过程中会留下线条
Anyway, as I already said I would use a RelativeLayout, place the buttons as required by setting their marginLeft/marginTop values accordingly. This leaves the buttons independent of each other.
无论如何,正如我已经说过的,我将使用RelativeLayout,通过相应地设置marginLeft / marginTop值来根据需要放置按钮。这使按钮彼此独立。
Then in your animation code change the margin and dimension values of the current button as required.
然后在动画代码中根据需要更改当前按钮的边距和尺寸值。
#3
0
In the end I decided to go with the AbsoluteLayout
最后我决定选择AbsoluteLayout