For instance, I have TextView_A and TextView_B in one RelativeLayout, TextView_A covers TextView_B. Now I would like TextView_B cover TextView_A in run time, how can I do that? Thanks so much.
Asked
Active
Viewed 115 times
1 Answers
1
What do you mean by "cover"? Like them overlapping each other or is one on top of the other like if it's beneath it
If you are asking how to position a thing underneath another in a Relative Layout, you could use the layout_below attribute as seen here
Edit: To do that during runtime you would need to do it through java. You can easily set the top view to invisible to make the bottom visible like this
myView.setVisibility(View.GONE);

maxib7
- 1,912
- 2
- 13
- 18
-
No, What I mean is that View1 is under View2, we can just see View2. Now, I would like to set View1 on the top of View2 during running time, it means that we can just see View1 and View2 is covered by View1. – Kame Li Jun 21 '15 at 03:40
-
-
Check my edited version. It's simple and might work for your needs. Other than first getting reference to it, it only takes one line – maxib7 Jun 21 '15 at 03:51
-
Thanks a lot. Actually, what I really need to do is to set view2 in half transparent, and we still can see view1 even it is overlapped by view2. Is there any way to fulfill this feature? – Kame Li Jun 21 '15 at 03:56
-
Tell me if this helps http://developer.android.com/reference/android/view/View.html#setAlpha%28float%29 if you want it to be a certain transparency forever you can use android:alpha="0.5" as an attribute or you can try this http://stackoverflow.com/questions/20643999/button-opacity-transparency – maxib7 Jun 21 '15 at 04:02
-
1Really thank you all. I fixed this issue by following code. childView1.bringToFront(); parentView.invalidate(); – Kame Li Jun 21 '15 at 04:38