user3576118 user3576118 - 4 months ago 80x
Android Question

ScaleType in ImageView not working

I am trying to make a gallery of images using ViewPager and Volley's NetworkImageView. Everything is working fine with the viewpager and image retrieve. But when i put the bitmap in the NetworkImageView, the image is not stretched to fill the size of the NetworkImageView. With my other ImageView, setting the scaleType works just fine.

android:scaleType="fitXY" />

My xml file

public static class SwipeFragment extends Fragment {

ImageLoader imageLoader = AppController.getInstance().getImageLoader();

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View swipeView = inflater.inflate(R.layout.swipe_fragment, container, false);
NetworkImageView imageView = (NetworkImageView) swipeView.findViewById(;
Bundle bundle = getArguments();
int position = bundle.getInt("position");
if (imageLoader == null) {
imageLoader = AppController.getInstance().getImageLoader();
imageView.setImageUrl(fotoUrl.get(position), imageLoader);
return swipeView;


static SwipeFragment newInstance(int position) {
SwipeFragment swipeFragment = new SwipeFragment();
Bundle bundle = new Bundle();
bundle.putInt("position", position);
return swipeFragment;

My java

Any idea about this problem?
I have also tried to change the scaleType into fitCenter but still the same results. Thank you in advance.


I think your issue is because of the wrap_content values used for width and height. Try to use the below code and it should work.

    android:scaleType="fitXY" />

When you say wrap_content that means you are asking view to be of same height and width of the image hence scaling doesn't apply. When you fix the width and height then you can apply fitXY scale type.