繁体   English   中英

使用Glide Library时,小尺寸图像会自动调整大小

[英]Image of small dimensions automatically resizes when using Glide Library

我对GIF调整大小有疑问。 我的GIF尺寸是136*136像素,我正在尝试使用Glide库将其加载到图像视图中(其宽度和高度设置为wrap_content )。 但GIF最终会占据整个屏幕。 我的XML文件代码段如下所示:

ImageView
    android:id="@+id/loading_animation"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:adjustViewBounds="true"
    tools:src="@drawable/gif_loading_animation"
    android:foregroundGravity="center" />

我的主要活动代码看起来像这样:

Glide.with(getContext())
            .load(R.drawable.gif_loading_animation)
            .asGif()
            .into(loadingAnimation);

是否有任何解决方案可以避免在不使用任何硬代码参数宽度和高度的情 :)

您可以尝试使用.override(Target.SIZE_ORIGINAL)

    Glide.with(getContext())
     .load(R.drawable.gif_loading_animation)
     .asGif()
     .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
     .into(loadingAnimation);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM