SetMargins Method does Nothing

Nathan Sokalski 4,111 Reputation points
2022-12-04T03:02:23.367+00:00

I am attempting to programmatically set the margins of several View(s) using the SetMargins method using code similar to the following:

(this.btnNewPicture.LayoutParameters as LinearLayout.LayoutParams).SetMargins((int)(137.5 + 72), 0, 0, 0);  

This does not seem to do anything. If I set the margins in xml it works fine. What is the problem?

Developer technologies | .NET | Xamarin
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.