How to add view to left of another view programmatically

ErinBearinErinBearin USMember ✭✭
edited January 2017 in Xamarin.Android

I am writing an application that allows the user to upload images programmatically, and the images are displayed in a line, with the first image on the left, the next image to the right of the first, the next image to the right, and so on. I am trying to find a way where the first image will shift to the right to make room for the next image on the left of it. I want the most recently uploaded image to appear on the left. I've tried to work with relative layouts to accomplish this by setting the parameters, but the second image is always on top of the first image. In my code, 'lastImage' is the previous image added to the layout, and 'image' is the current one being added. This code is supposed to reset the lastImage parameters so it is displayed on the right side of the current image.

RelativeLayout.LayoutParams lastParams = (RelativeLayout.LayoutParams)lastImage.LayoutParameters; lastParams.AddRule(LayoutRules.RightOf, image.Id);

I also have made sure to set AlignParentRight in the parameters.

Does anyone know a way to shift pictures to the right so the current image is displayed on the left? Any suggestions would be helpful.
Thanks.

Best Answer

Answers

Sign In or Register to comment.