我有一个ImageView,它填满了整个屏幕,我从url下载图像到我的SD卡中,我正在使用AnimationDrawable将这些图像显示为幻灯片放映在ImageView中。但是,无论如何尝试,我的图片都失去了它们的纵横比,图像会出现拉伸的情况。我已经尝试了所有的ImageView的缩放类型,但是没有用。这是我的代码:
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。