void DefineAnimations(int screenWidth) { Logging.Log (this, Logging.LoggingTypeDebug, "DefineAnimations()"); // define animations leftOutAnim = new TranslateAnimation(0, -300, 0, 0); leftOutAnim.Duration = animDuration; leftOutAnim.SetAnimationListener(this); rightOutAnim = new TranslateAnimation (0, screenWidth, 0, 0); rightOutAnim.Duration = animDuration; rightOutAnim.SetAnimationListener (this); leftInAnim = new TranslateAnimation (-300, 0, 0, 0); leftInAnim.Duration = animDuration; leftInAnim.SetAnimationListener (this); rightInAnim = new TranslateAnimation (screenWidth, 0, 0, 0); rightInAnim.Duration = animDuration; rightInAnim.SetAnimationListener (this); }
public IndicatorLayout(Context context, Mode mode) :base(context) { //super(context); mArrowImageView = new ImageView(context); Drawable arrowD =Resources.GetDrawable(Resource.Drawable.indicator_arrow); mArrowImageView.SetImageDrawable(arrowD); int padding = Resources.GetDimensionPixelSize(Resource.Dimension.indicator_internal_padding); mArrowImageView.SetPadding(padding, padding, padding, padding); AddView(mArrowImageView); int inAnimResId, outAnimResId; switch (mode) { case Mode.PULL_FROM_END: inAnimResId = Resource.Animation.slide_in_from_bottom; outAnimResId = Resource.Animation.slide_out_to_bottom; SetBackgroundResource(Resource.Drawable.indicator_bg_bottom); // Rotate Arrow so it's pointing the correct way mArrowImageView.SetScaleType(Android.Widget.ImageView.ScaleType.Matrix); Matrix matrix = new Matrix(); matrix.SetRotate(180f, arrowD.IntrinsicWidth/ 2f, arrowD.IntrinsicHeight/ 2f); mArrowImageView.ImageMatrix=matrix; break; default: case Mode.PULL_FROM_START: inAnimResId = Resource.Animation.slide_in_from_top; outAnimResId = Resource.Animation.slide_out_to_top; SetBackgroundResource(Resource.Drawable.indicator_bg_top); break; } mInAnim = AnimationUtils.LoadAnimation(context, inAnimResId); mInAnim.SetAnimationListener(this); mOutAnim = AnimationUtils.LoadAnimation(context, outAnimResId); mOutAnim.SetAnimationListener(this); IInterpolator interpolator = new LinearInterpolator(); //mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f); mRotateAnimation = new RotateAnimation(0, -180, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); mRotateAnimation.Interpolator=interpolator; mRotateAnimation.Duration=DEFAULT_ROTATION_ANIMATION_DURATION; mRotateAnimation.FillAfter=true; mResetRotateAnimation = new RotateAnimation(-180, 0, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); mResetRotateAnimation.Interpolator=interpolator; mResetRotateAnimation.Duration=DEFAULT_ROTATION_ANIMATION_DURATION; mResetRotateAnimation.FillAfter=true; }