title: ViewPager using FragmentPagerAdapter lagging while swiping
body: <p>I have a ViewPager that uses a FragmentPagerAdapter. I'm using images of size 2048 * 1536 to display in the ViewPager. </p>
  
  <p>When I swipe the ViewPager, it is lagging little bit. 
  Am I doing anything wrong here that causes the lag ?</p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
      static final int NUM_ITEMS = 6;
      ImageFragmentPagerAdapter imageFragmentPagerAdapter;
      ViewPager viewPager;
      public static final String[] IMAGE_NAME = 
      {"image1", "image2", "image3", "image4", "image5", "image6", "image7"};
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.fragment_pager);
          imageFragmentPagerAdapter = 
          new ImageFragmentPagerAdapter(getSupportFragmentManager());
          viewPager = (ViewPager) findViewById(R.id.pager);
          viewPager.setAdapter(imageFragmentPagerAdapter);
      }
  
      public static class ImageFragmentPagerAdapter extends FragmentPagerAdapter {
          public ImageFragmentPagerAdapter(FragmentManager fm) {
              super(fm);
          }
  
          @Override
          public int getCount() {
              return NUM_ITEMS;
          }
  
          @Override
          public Fragment getItem(int position) {
              SwipeFragment fragment = new SwipeFragment();
              return SwipeFragment.newInstance(position);
          }
      }
  
      public static class SwipeFragment extends Fragment {
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              View swipeView = inflater.inflate(R.layout.swipe_fragment, container, false);
              ImageView imageView = (ImageView) swipeView.findViewById(R.id.imageView);
              Bundle bundle = getArguments();
              int position = bundle.getInt("position");
              String imageFileName = IMAGE_NAME[position];
              int imgResId = getResources().getIdentifier(imageFileName, "drawable", 
                                "com.viewpager.viewpagerusingfragmentpageradapter");
              imageView.setImageResource(imgResId);
              return swipeView;
          }
  
          static SwipeFragment newInstance(int position) {
              SwipeFragment swipeFragment = new SwipeFragment();
              Bundle bundle = new Bundle();
              bundle.putInt("position", position);
              swipeFragment.setArguments(bundle);
              return swipeFragment;
          }
      }
  }
  </code></pre>