使用Volley Android缩放ImageView

使用Volley Android缩放ImageView,android,image-processing,android-volley,Android,Image Processing,Android Volley,使用Volley库和ViewPager创建图像库时,我偶然发现了缩放不同宽度和高度的图像的问题。比如说..横向模式图像和纵向模式图像。纵向图像显示正常,但横向图像是按宽度剪切的。例如,我想要设置的视图页面高度固定为300dp 我真的不明白。。。下面是我的代码: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceSt

使用Volley库和ViewPager创建图像库时,我偶然发现了缩放不同宽度和高度的图像的问题。比如说..横向模式图像和纵向模式图像。纵向图像显示正常,但横向图像是按宽度剪切的。例如,我想要设置的视图页面高度固定为300dp

我真的不明白。。。下面是我的代码:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.cell, container, false);

        final NetworkImageView imageView = (NetworkImageView) view
                .findViewById(R.id.imageCell);

        RequestQueue queue = VolleySingleton.getInstance(getActivity())
                .getRequestQueue();
        ImageLoader imageLoader = VolleySingleton.getImageLoader();
        imageLoader.get(photoUrl, new ImageListener() {

            public void onErrorResponse(VolleyError error) {
                imageView.setImageResource(R.drawable.unnamed); 
            }

            public void onResponse(ImageContainer response, boolean arg1) {
                if (response.getBitmap() != null) {
                    imageView.setImageBitmap(response.getBitmap());
                }
            }
        });
        imageView.setImageUrl(photoUrl, imageLoader);

        return view;
    }

Cell.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:orientation="vertical" >

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/imageCell"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:background="@drawable/unnamed"
        android:scaleType="centerCrop" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <android.support.v4.view.ViewPager
        android:id="@+id/photoPager"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:minHeight="100dp"
        android:layout_weight="1"  />

</LinearLayout>


我希望有人已经通过这个问题之前,任何提示将是伟大的。谢谢。
NetworkImageView
上的android:scaleType=“fitCenter”应该可以做到这一点。

EUREKA!!!有太多的帖子解释了关于如何扩展类的冗长答案,疯狂的东西。。。但这是可行的。谢谢