AnOldSoul
AnOldSoul

Reputation: 4207

Translate animation relative to parent using xamarin

I have the below code in Java where I create a translate animation relative to the parent. What is the Xamarin equivalent code for this? The Animation class in C# doesn't seem to have these attributes.Any help would be much appreciated.

            Animation inFromBottom = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);

Upvotes: 0

Views: 611

Answers (1)

Grace Feng
Grace Feng

Reputation: 16652

In Xamarin.Android, attributes like Animation.RELATIVE_TO_PARENT and Animation.RELATIVE_TO_SELF are encapsulated into Android.Views.Animations.Dimension Enumeration.

You can modify your code like this:

Animation inFromBottom = new TranslateAnimation(
Dimension.RelativeToParent, 0.0f,
Dimension.RelativeToParent, 0.0f,
Dimension.RelativeToParent, 1.0f,
Dimension.RelativeToParent, 0.0f);

Upvotes: 3

Related Questions