android imageview缩放类型不适用于AnimationDrawable

android imageview缩放类型不适用于AnimationDrawable,android,android-layout,imageview,android-animation,Android,Android Layout,Imageview,Android Animation,我有一个充满我整个屏幕的imageview,我将图像从url下载到SD卡中,我使用AnimationDrawable在imageview中以幻灯片形式显示这些图像。但是,无论我如何尝试,我的图像都失去了纵横比,图像似乎被拉伸了。我已经尝试了imageview的所有scaletype,但没有用。这是我的密码: AnimationDrawable animation = new AnimationDrawable(); File cacheDir = AlRimal.getDataF

我有一个充满我整个屏幕的imageview,我将图像从url下载到SD卡中,我使用AnimationDrawable在imageview中以幻灯片形式显示这些图像。但是,无论我如何尝试,我的图像都失去了纵横比,图像似乎被拉伸了。我已经尝试了imageview的所有scaletype,但没有用。这是我的密码:

    AnimationDrawable animation = new AnimationDrawable();
    File cacheDir = AlRimal.getDataFolder(Main_Load.this);
    File cacheFile = new File(cacheDir, "file_1.jpg");
    Drawable d = Drawable.createFromPath(cacheFile.getPath());
    Bitmap bitmap = BitmapFactory.decodeFile(cacheFile.getPath());
    animation.addFrame(d, 5000);
    animation.addFrame(d, 5000);
    animation.addFrame(d, 5000);
    animation.setOneShot(false);
    animation.setExitFadeDuration(500);
    animation.setEnterFadeDuration(500);
    animationImg.setScaleType(ScaleType.FIT_CENTER);//All possibilities have been tried
    animationImg.setBackgroundDrawable(animation);
    animation.start();

我的图像的资源是:2048*1536

未设置
缩放类型
,因为
图像视图
中的图像被设置为背景。当我将其更改为源代码时,它工作了。

而不是

animationImg.setBackgroundDrawable(动画)

尝试使用

animationImg.setImageDrawable(animation);