4

ViewPager と Volley の NetworkImageView を使用して画像のギャラリーを作成しようとしています。ビューページャーと画像取得ですべてが正常に機能しています。しかし、ビットマップを NetworkImageView に入れると、画像は NetworkImageView のサイズに合わせて引き伸ばされません。私の他の ImageView では、scaleType の設定は問題なく機能します。

<com.android.volley.toolbox.NetworkImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitXY" />

私のxmlファイル

public static class SwipeFragment extends Fragment {

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

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View swipeView = inflater.inflate(R.layout.swipe_fragment, container, false);
        NetworkImageView imageView = (NetworkImageView) swipeView.findViewById(R.id.imageView);
        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);
        swipeFragment.setArguments(bundle);
        return swipeFragment;
    }
}

私のJava

この問題について何か考えはありますか?また、scaleType を fitCenter に変更しようとしましたが、結果は同じです。前もって感謝します。

4

1 に答える 1

4

あなたの問題は、幅と高さに使用される wrap_content 値が原因だと思います。以下のコードを使用してみてください。動作するはずです。

<com.android.volley.toolbox.NetworkImageView
    android:id="@+id/imageView"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:scaleType="fitXY" />

wrap_content と言うと、ビューが画像と同じ高さと幅になるように要求しているため、スケーリングは適用されません。幅と高さを固定すると、fitXY スケール タイプを適用できます。

于 2016-06-19T11:29:12.750 に答える