I have very simple imageview app that is suppose to set the wallpaper when the user click on any image. However, my problem is that as I am displaying full image in viewpager. And when user click on the image it takes the whole screen of the device or emulator. In other words image appear to be distorted or cut in Home screen. Can any one please suggest the code on how to fix this issue or what am I missing in my code ?... I believe that I have to change ImageAdpater code.. But I am not sure.... 
Following are my codes..

Mainactivity.java

```
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ShareActionProvider;

public class MainActivity extends Activity {

    MediaPlayer oursong;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
      oursong = MediaPlayer.create(MainActivity.this, R.raw.a);
      oursong.start ();
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    ImageAdapter adapter = new ImageAdapter(this);
    viewPager.setAdapter(adapter);
  }

  private ShareActionProvider mShareActionProvider;

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate menu resource file.
      getMenuInflater().inflate(R.menu.activity_main, menu);

      // Locate MenuItem with ShareActionProvider
      MenuItem item = menu.findItem(R.id.menu_item_share);

      // Fetch and store ShareActionProvider
      mShareActionProvider = (ShareActionProvider) item.getActionProvider();

      // Return true to display menu
      return true;
  }

  // Call to update the share intent
  private void setShareIntent(Intent shareIntent) {
      if (mShareActionProvider != null) {
          mShareActionProvider.setShareIntent(shareIntent);
      }
  }

     @Override
     protected void onPause(){
     super.onPause();
      oursong.release();
 }

}

```

Imageadapter.java

```
import java.io.IOException;

import android.app.WallpaperManager;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class ImageAdapter extends PagerAdapter {
    Context context;
    private final int[] GalImages = new int[] {
        R.drawable.one,
        R.drawable.two,
        R.drawable.three
    };
    ImageAdapter(Context context){
        this.context=context;
    }
    @Override
    public int getCount() {
      return GalImages.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
      return view == ((ImageView) object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
      ImageView imageView = new ImageView(context);
      int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_small);
      imageView.setPadding(padding, padding, padding, padding);
      imageView.setScaleType(ImageView.ScaleType.FIT_XY);
      imageView.setImageResource(GalImages[position]);

      imageView.setOnClickListener(new View.OnClickListener() {

           public void onClick(View view) {

                    WallpaperManager myWallpaperManager  = WallpaperManager.getInstance(context);
                    try {
                            myWallpaperManager.setResource(GalImages[position]);
                    } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                    }       

           }

           });

      ((ViewPager) container).addView(imageView, 0);
      return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
      ((ViewPager) container).removeView((ImageView) object);
    }
  }

```