title: Moving view items using ViewPager.PageTransformer()
body: <p>I'm working on an intro on my app.  When it first launches, you should see a card in the middle of the screen.  When you move the viewpager page to the next position (from 1 to 2), that card should animate down and to the left off the screen.</p>
  
  <p>I did a bunch of searching and came to the conclusion that the PageTransformer is where I need to be looking. </p>
  
  <p>The problem is that I can't really find any docs on the pageTransformer other than working with transition animations which I'm not trying to do.</p>
  
  <p>Can anybody point me to a good example or tutorial for what I'm trying to accomplish OR does anybody have a better option than pageTransformer?</p>
  
  <p>I can get the element to move, but I can't figure out where the starting position is coming from (if I do a setX before setting the transformer, it's seemingly ignored).</p>
  
  <p>Here's what I have in code:</p>
  
  <pre><code>   package com.example.myapplication.app;
  
  import android.app.Activity;
  import android.graphics.Point;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.app.FragmentStatePagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.support.v7.app.ActionBarActivity;
  import android.util.DisplayMetrics;
  import android.util.Log;
  import android.view.*;
  import android.view.animation.LinearInterpolator;
  import android.widget.LinearLayout;
  import android.widget.RelativeLayout;
  
  
  public class MainActivity extends ActionBarActivity {
  
      private static final int NUM_PAGES = 5;
  
      View card1;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          RelativeLayout papa = (RelativeLayout) findViewById(R.id.mainLayout);
          card1 = getLayoutInflater().inflate(R.layout.small_card, papa, false);
  
          papa.addView(card1);
  
          ViewPager pager = (ViewPager) findViewById(R.id.pager);
          pager.setAdapter(new ScreenSlidePagerAdapter(getSupportFragmentManager()));
          pager.setPageTransformer(true, new ViewPager.PageTransformer() {
              @Override
              public void transformPage(View view, float position) {
                  int pageWidth = view.getWidth();
  
                  if (position &lt;= -1) { // [-Infinity,-1)
                      // This page is way off-screen to the left.
                  } else if (position &lt;= 1) { // [-1,1]
                      card1.setTranslationX(-(position) * (pageWidth + card1.getWidth()));
  
                  } else { // (1,+Infinity]
                      // This page is way off-screen to the right.
                  }
              }
          });
  
          pager.setCurrentItem(1);
      }
  
      private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
          public ScreenSlidePagerAdapter(FragmentManager fm) {
              super(fm);
          }
  
          @Override
          public Fragment getItem(int position) {
              return new ViewPagerFragment();
          }
  
          @Override
          public int getCount() {
              return NUM_PAGES;
          }
      }
  }
  </code></pre>