Background:
I have an Activity that comprises four buttons that each take up a quarter of the screen.
It contains a horizontal LinearLayout that is divided in half by two vertical LinearLayouts as shown in the image below:
https://i.stack.imgur.com/P7Wd3.jpg
Desired Effect:
When I touch a button, I would like it to animate and fill up the entire screen.
Issue:
I have accomplished the animation aspect by changing X and Y scales from 1 to 2 onClick.
The problem is, however, that the animated button will not show when it leaves its parent LinearLayout.
Thoughts
-
I have tried making the non-animated buttons invisible, but the animated button will only show in its parent LinearLayout.
-
I know this problem would be solved if I had used a single LinearLayout, but I was unable to use the “layout:weight” feature to make each button take up half of both width and length.
So… How should I approach this issue?
I would appreciate any help 🙂
Try using a single
RelativeLayout. Check this post for a nice example. You may have tosetVisibility(View.INVISIBLE)for the other buttons.Alternative:
RelativeLayoutas above but put that as the only childof a
FrameLayout.RelativeLayoutand add it to theFrameLayoutspecifying the gravity in theLayoutParamsappropriately. This way the rest of the buttons will also be seen in the background during the animation.