Forum Xamarin.Android

Changing positions of views in relativelayout


I want to change the relative positions of 2 linearlayouts in a relativelayout. Within the relativelayout view2 is below view1. I want to change this order programmatically to view2 above view1. For some reason it does not seem possible to put another view (view2) above the first view (view1).
I use to following code:
var ll = (LinearLayout) FindViewById(Resource.Id.viewgroup2LL);
RelativeLayout.LayoutParams par = new RelativeLayout.LayoutParams(ll.LayoutParameters);
par.AddRule(LayoutRules.Above, Resource.Id.viewgroup1LL);
ll.LayoutParameters = par;
With 3 linearlayouts it is possible to change the order of the second and the third layout, but is seems not possible to place a layout above the first.

Am I missing something? Is there a smart way to do this without complety removing the first layout and creating a new one below the second layout?


  • CheesebaronCheesebaron DKInsider, University mod

    What exactly do you see with that code? Is the first layout at the top of the RelativeLayout?

  • KeesPaulKeesPaul NLMember ✭✭

    Yep. I tested with 4 layouts, and some below the first you can switch places, but sometimes they end up on top of eachother and with only two the second dissapears, as if it is above the first, but not visible anymore.

Sign In or Register to comment.