Java Code Examples for android.view.View.TRANSLATION_X

The following are Jave code examples for showing how to use TRANSLATION_X of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: magellan   File: DefaultTransition.java   Source Code and License Vote up 5 votes
private AnimatorSet createAnimator(View from, View to, NavigationType navType, Direction direction) {
  Property<View, Float> axis;
  int fromTranslation;
  int toTranslation;
  int sign = direction.sign();

  switch (navType) {
    case GO:
      axis = View.TRANSLATION_X;
      fromTranslation = sign * -from.getWidth();
      toTranslation = sign * to.getWidth();
      break;
    case SHOW:
      axis = View.TRANSLATION_Y;
      fromTranslation = direction == FORWARD ? 0 : from.getHeight();
      toTranslation = direction == BACKWARD ? 0 : to.getHeight();
      break;
    default:
      axis = View.TRANSLATION_X;
      fromTranslation = 0;
      toTranslation = 0;
      break;
  }
  AnimatorSet set = new AnimatorSet();
  if (from != null) {
    set.play(ObjectAnimator.ofFloat(from, axis, 0, fromTranslation));
  }
  set.play(ObjectAnimator.ofFloat(to, axis, toTranslation, 0));
  return set;
}