I have activity and a lot of widgets on it, some of them have animations and because of the animations some of the widgets are moving (translating) one over another. For example the text view is moving over some buttons . . .
Now the thing is I want the buttons to be always on the front. And when the textview is moving I want to move behind the buttons.
I can not achieve this I tried everything I know, and "bringToFront()" definitelly doesn't work.
note I do not want to control the z-order by the order of placing element to layout cause I simply can't :), the layout is complex and I can not place all the buttons at the begging of the layout
Try
FrameLayout
, it gives you the possibility to put views one above another. You can create twoLinearLayouts
: one with the background views, and one with foreground views, and combine them using theFrameLayout
. Hope this helps.You need to use framelayout. And the better way to do this is to make the view invisible when thay are not require. Also you need to set the position for each and every view,So that they will move according to there corresponding position
An even simpler solution is to edit the XML of the activity. Use
You can try to use the
bringChildToFront
, you can check if this documentation is helpful in the Android Developers page.You can set visibility to false of other views.
or
and set
i have faced the same problem. the following solution have worked for me.