SetMargins Method does Nothing

Nathan Sokalski 4,106 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?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,115 questions
{count} votes