title: How to avoid surfaceview shrinking when scrolled?
body: <p>In my project i have a requirement to have horizontal listview with item being surfaceview's displaying video , as i scroll the list view next video has to be displayed, it works fine in all the phones and tablets ,but in LG NEXUS 4 when i perform scroll the surfaceview is shrinking, please provide any suggestions.</p>
  
  <p>Thanks.</p>
  
  <p>please find the related code here.</p>
  
  <pre><code>enter code herepackage com.example.videopager;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.support.v4.view.ViewPager;
  import android.view.Menu;
  
  public class MainActivity extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          MyPagerAdapter adapter = new MyPagerAdapter();
          ViewPager myPager = (ViewPager) findViewById(R.id.myfivepanelpager);
          myPager.setAdapter(adapter);
          myPager.setCurrentItem(1);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  package com.example.videopager;
  
  import android.content.Context;
  import android.net.Uri;
  import android.os.Parcelable;
  import android.support.v4.view.PagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.widget.VideoView;
  
  public class MyPagerAdapter extends PagerAdapter {
  
      public VideoView mVideoView;
  
      public int getCount() {
          return 3;
      }
  
      public Object instantiateItem(View collection, int position) {
          LayoutInflater inflater = (LayoutInflater) collection.getContext()
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          int resId = 0;
          View view = null;
          switch (position) {
          case 0:
              resId = R.layout.video1;
              view = inflater.inflate(resId, null);
  
              break;
          case 1: // TODO : change media file path accordingly
              resId = R.layout.video2;
              view = inflater.inflate(resId, null);
              {
                  try {
                      mVideoView = (VideoView) view
                              .findViewById(R.id.playback_view);
                      String videourl = "sdcard/Download/WakaWaka.mp4";
                      mVideoView.requestFocus();
                      mVideoView.setVideoURI(Uri.parse(videourl));
                      mVideoView.start();
                  } catch (Exception e) {
                      // TODO: handle exception
                  }
              }
              break;
          case 2:
              resId = R.layout.video3;
              view = inflater.inflate(resId, null);
  
              break;
          }
          ((ViewPager) collection).addView(view, 0);
  
          return view;
      }
  
      @Override
      public void destroyItem(View arg0, int arg1, Object arg2) {
          ((ViewPager) arg0).removeView((View) arg2);
      }
  
      @Override
      public Parcelable saveState() {
          return null;
      }
  
      @Override
      public boolean isViewFromObject(View arg0, Object arg1) {
          return arg0 == ((View) arg1);
      }
  }
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;VideoView
          android:id="@+id/playback_view"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
           /&gt;
  
  
  &lt;/FrameLayout&gt;
  </code></pre>