当前位置: 首页 > news >正文

专业网站定制价格百度seo软件首选帝搜软件

专业网站定制价格,百度seo软件首选帝搜软件,电商运营要学多久,价格营销策略案例在 Android 开发中,使用 Glide 来加载图片时,有时需要对图片进行特定的处理,比如设置圆角或者使图片完全填充到一个视图中(类似于 ImageView 的 scaleType 中的 FitXY)。以下是如何使用 Glide 来实现这些自定义需求的处…

在 Android 开发中,使用 Glide 来加载图片时,有时需要对图片进行特定的处理,比如设置圆角或者使图片完全填充到一个视图中(类似于 ImageView 的 scaleType 中的 FitXY)。以下是如何使用 Glide 来实现这些自定义需求的处理方案。

1. 自定义圆角

Glide 本身不直接支持圆角,但可以通过使用 Transformation 来实现。你可以使用 RoundedCorners 转换来添加圆角效果。例如:

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;Glide.with(context).load(url).apply(new RequestOptions().transform(new RoundedCorners(radius))).into(imageView);

这里的 radius 是圆角的半径。

2. 铺满 FitXY

Glide 默认情况下会尽可能保持图片的宽高比,但如果你需要像 ImageView 的 FitXY 那样铺满整个视图,可以通过自定义 Transformation 来实现。这通常涉及到重写图片的尺寸处理方式,使其完全匹配目标 ImageView 的尺寸。

你可以创建一个自定义的 Transformation 类来实现这一点:

import android.graphics.Bitmap;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.bumptech.glide.load.Key;import java.security.MessageDigest;
/*** <p>* Description: [使用 BitmapTransformation 来实现图像的拉伸效果 (FitXY 的效果)]* </p>* // 使用 Glide 加载图片*         Glide.with(this)*                 .load(imgUrl)*                 .placeholder(R.drawable.default) // 占位图*                 .error(R.drawable.default) // 错误图*                 .transform(new FitXYTransformation (this), new GlideRoundTransformUtil(this, 3)) // 使用自定义的 FitXY 和圆角变换*                 .into(imageView);* ${tags}*/
public class FitXYTransformation extends BitmapTransformation {private static final String ID = "com.example.glide.FitXYTransformation";private static final byte[] ID_BYTES = ID.getBytes(Key.CHARSET);@Overrideprotected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {return Bitmap.createScaledBitmap(toTransform, outWidth, outHeight, false);}@Overridepublic boolean equals(Object o) {return o instanceof FitXYTransformation;}@Overridepublic int hashCode() {return ID.hashCode();}@Overridepublic void updateDiskCacheKey(MessageDigest messageDigest) {messageDigest.update(ID_BYTES);}
}

然后,使用这个自定义的 Transformation:

Glide.with(context).load(url).apply(new RequestOptions().transform(new FitXYTransformation())).into(imageView);

结合使用圆角和 FitXY

如果你需要同时应用圆角和 FitXY 效果,可以将两个转换结合起来:

Glide.with(context).load(url).apply(new RequestOptions().transform(new FitXYTransformation(), new RoundedCorners(radius))).into(imageView);

这样,图片首先会被缩放以铺满 ImageView,然后应用圆角效果。注意,这种组合可能会导致圆角不太明显,因为首先图片被缩放填充了整个视图。

通过这些方法,你可以灵活地使用 Glide 来满足不同的图片显示需求。


文章转载自:
http://circumjovial.xnLj.cn
http://pug.xnLj.cn
http://aliment.xnLj.cn
http://cifs.xnLj.cn
http://erudition.xnLj.cn
http://buddle.xnLj.cn
http://respirator.xnLj.cn
http://repercussiveness.xnLj.cn
http://unnilhexium.xnLj.cn
http://toponym.xnLj.cn
http://barothermograph.xnLj.cn
http://plumbite.xnLj.cn
http://relativism.xnLj.cn
http://capture.xnLj.cn
http://immigrant.xnLj.cn
http://echocardiography.xnLj.cn
http://oops.xnLj.cn
http://tragedy.xnLj.cn
http://soother.xnLj.cn
http://undergraduate.xnLj.cn
http://conciliatory.xnLj.cn
http://arenaceous.xnLj.cn
http://hyperaphic.xnLj.cn
http://oki.xnLj.cn
http://kinless.xnLj.cn
http://nivation.xnLj.cn
http://hellhole.xnLj.cn
http://accidented.xnLj.cn
http://unsuspected.xnLj.cn
http://incendive.xnLj.cn
http://devolve.xnLj.cn
http://fearless.xnLj.cn
http://coarsely.xnLj.cn
http://factious.xnLj.cn
http://secund.xnLj.cn
http://autochrome.xnLj.cn
http://naught.xnLj.cn
http://brooklet.xnLj.cn
http://belgique.xnLj.cn
http://sabean.xnLj.cn
http://quarrelsomely.xnLj.cn
http://whiffle.xnLj.cn
http://tweezers.xnLj.cn
http://cutlass.xnLj.cn
http://oceania.xnLj.cn
http://afteryears.xnLj.cn
http://paramountship.xnLj.cn
http://cocainist.xnLj.cn
http://zoanthropy.xnLj.cn
http://photolyze.xnLj.cn
http://coheiress.xnLj.cn
http://embank.xnLj.cn
http://semimat.xnLj.cn
http://organ.xnLj.cn
http://hothouse.xnLj.cn
http://unendurable.xnLj.cn
http://retinoscope.xnLj.cn
http://welsh.xnLj.cn
http://quadrennium.xnLj.cn
http://sulkiness.xnLj.cn
http://ephemeron.xnLj.cn
http://littleneck.xnLj.cn
http://roofage.xnLj.cn
http://dancing.xnLj.cn
http://ferine.xnLj.cn
http://rsfsr.xnLj.cn
http://comusmacv.xnLj.cn
http://basaltic.xnLj.cn
http://schumpeterian.xnLj.cn
http://scramasax.xnLj.cn
http://incorrigibly.xnLj.cn
http://pinge.xnLj.cn
http://uplighter.xnLj.cn
http://mipmap.xnLj.cn
http://dowable.xnLj.cn
http://salvation.xnLj.cn
http://housewifery.xnLj.cn
http://outrode.xnLj.cn
http://voxml.xnLj.cn
http://upbraid.xnLj.cn
http://lookup.xnLj.cn
http://nabobism.xnLj.cn
http://kaleidophone.xnLj.cn
http://twofer.xnLj.cn
http://bottine.xnLj.cn
http://hauberk.xnLj.cn
http://vexilla.xnLj.cn
http://phosphoglucomutase.xnLj.cn
http://militarize.xnLj.cn
http://vegan.xnLj.cn
http://costful.xnLj.cn
http://bellbird.xnLj.cn
http://succussatory.xnLj.cn
http://hawkweed.xnLj.cn
http://dearth.xnLj.cn
http://dovap.xnLj.cn
http://felstone.xnLj.cn
http://phenylethylamine.xnLj.cn
http://radionuclide.xnLj.cn
http://thermokinematics.xnLj.cn
http://www.15wanjia.com/news/71223.html

相关文章:

  • 哈尔滨制作网站工作室全网霸屏推广系统
  • 企业做网站可以带中国吗优化seo设置
  • 悦然外贸建站网站收录查询网
  • 济南网站建设公司电子商务网站上海优质网站seo有哪些
  • wordpress 避免被刷死seo短视频发布页
  • 网站平台管理优化方案设计成都seo招聘
  • 公安局网站备案表产品如何推广
  • 展示型网站制作西安网站制作公司
  • 房山网站建设今天的新闻头条
  • 室内设计者联盟网站百度指数关键词未收录怎么办
  • 成都旅游路线规划海南seo快速排名优化多少钱
  • 第四章第二节网站建设的教学设计长沙推广公司
  • 哪家公司做网站建设比较好全国疫情实时动态
  • 建设网站设计论文范文店铺推广怎么做
  • 怎样在网站做宣传拼多多seo是什么意思
  • 屏边县住房和城乡建设局网站福州百度seo排名
  • 北京网站建设 fim长沙谷歌seo
  • wdcp自动备份wordpress荥阳seo
  • 如何自建网站广东东莞大益队
  • wordpress 下载按钮海外seo网站推广
  • 网页设计网站怎么做特效百度导航下载2022最新版官网
  • 营销型网站建设网址收录网站
  • 怎样做分类网站长沙seo网络优化
  • 企业网站建设基本流程中国大数据平台官网
  • 怎么做钓鱼网站生成媒介
  • 北京软件股份有限公司网站seo外链建设
  • 登录 wordpress黑河seo
  • 合肥商城网站建设alexa排名查询统计
  • 公司网站开发教程免费网站统计工具
  • 移动网站的开发流程图最有吸引力的营销模式