We are trying to use an objectanimator proxy to animate the TopMargin property in Android (Xamarin).
However, we get this error:
[PropertyValuesHolder] Couldn't find setter/getter for property TopMargin with value type float
Note: we tried TopMargin, topMargin, GetTopMargin, getTopMargin, etc., thinking that it might be an issue of casing conversion betwen Java and C#, but it doesn't look to be the case.
Our code in the Activity starting the animation:
translation = new int[] {0, 300};
var anim2 = ObjectAnimator.OfInt( new MarginProxyAnimator(myview), "TopMargin",translation);
anim2.SetDuration(500);
anim2.Start();
Our proxy class:
public class MarginProxyAnimator : Java.Lang.Object
{
///... other code...
public int getTopMargin() {
var lp = (ViewGroup.MarginLayoutParams)mView.LayoutParameters;
return lp.TopMargin;
}
public void setTopMargin(int margin) {
var lp = (ViewGroup.MarginLayoutParams)mView.LayoutParameters;
lp.SetMargins(lp.LeftMargin, margin, lp.RightMargin, lp.BottomMargin);
mView.RequestLayout();
}
}
Any advise? a pointer to a working Xamarin sample using a proxy would be helpful.
thanks.