我怎么能调整与定制的高度和宽度的Andr​​oid

我怎么能调整与定制的高度和宽度的Andr​​oid

本文介绍了我怎么能调整与定制的高度和宽度的Andr​​oid GIF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用Koush /离子库,从互联网上的GIF加载到ImageView的,但我不能aspectly调整GIF格式,在调用功能调整,GIF变得仍

所以我的问题是,有没有什么办法可以在android系统aspectly调整GIF?

这是我的计算得到高度方面和图像的宽度是否有帮助

 最终诠释newWidth = deviceWidth;
最终诠释newHeight =(INT)((INT)newWidth *(imageHeight / imageWidth));


解决方案

我想我终于找到了解决方案,
与FIT_XY第一级图像,然后设置newHeight作为图像视图高度

  imageView.setScaleType(ScaleType.FIT_XY);
。imageView.getLayoutParams()高度= newHeight;

code段

  Ion.with(ImageView的)
    .animateGif(AnimateGifMode.ANIMATE)
    .load(imgUrl的)
    .setCallback(新FutureCallback< ImageView的>(){    @燮pressLint(NewApi)
    @覆盖
    公共无效onCompleted(例外为arg0,
    ImageView的ARG1){        imageView.getViewTreeObserver()。插件preDrawListener(
        新ViewTreeObserver.On preDrawListener(){
            在preDraw公共布尔(){                imageView.getViewTreeObserver()
                    .removeOn preDrawListener(本);                imageView.setScaleType(ScaleType.FIT_XY);
                。imageView.getLayoutParams()高度= newHeight;                返回true;
            }
        });
    }
});

I am using Koush/Ion library to load gif from internet into imageview but I cannot resize the gifs aspectly, upon calling resize function, gif becomes still

so my question is, is there any way I can resize gif aspectly in android ?

here's my calculation to get aspect height and width of image if that helps

final int newWidth = deviceWidth;
final int newHeight = (int) ((int) newWidth * (imageHeight / imageWidth));
解决方案

I think I finally found the solution,First scale image with FIT_XY and then set 'newHeight' as the height of image view

imageView.setScaleType(ScaleType.FIT_XY);
imageView.getLayoutParams().height = newHeight;

Code Snippet

Ion.with(imageView)
    .animateGif(AnimateGifMode.ANIMATE)
    .load(imgUrl)
    .setCallback(new FutureCallback < ImageView > () {

    @SuppressLint("NewApi")
    @Override
    public void onCompleted(Exception arg0,
    ImageView arg1) {

        imageView.getViewTreeObserver().addOnPreDrawListener(
        new ViewTreeObserver.OnPreDrawListener() {
            public boolean onPreDraw() {

                imageView.getViewTreeObserver()
                    .removeOnPreDrawListener(this);

                imageView.setScaleType(ScaleType.FIT_XY);
                imageView.getLayoutParams().height = newHeight;

                return true;
            }
        });
    }
});

这篇关于我怎么能调整与定制的高度和宽度的Andr​​oid GIF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 15:26