Android 具有自定义滑行目标的滑行圆角图像
示例
首先创建实用程序类或在所需的类中使用此方法
public class UIUtils {
public static BitmapImageViewTarget getRoundedImageTarget(@NonNull final Context context, @NonNull final ImageView imageView,
final float radius) {
return new BitmapImageViewTarget(imageView) {
@Override
protected void setResource(final Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(context.getResources(), resource);
circularBitmapDrawable.setCornerRadius(radius);
imageView.setImageDrawable(circularBitmapDrawable);
}
};
}正在载入图片:
Glide.with(context)
.load(imageUrl)
.asBitmap()
.into(UIUtils.getRoundedImageTarget(context, imageView, radius));因为使用asBitmap()动画,但是动画将被删除。您可以使用animate()方法在此位置使用自己的动画。
淡入默认Glide动画的示例。
Glide.with(context)
.load(imageUrl)
.asBitmap()
.animate(R.anim.abc_fade_in)
.into(UIUtils.getRoundedImageTarget(context, imageView, radius));请注意,此动画是支持库的私有资源-不建议使用,因为它可以更改甚至被删除。
请注意,您还需要具有支持库才能使用RoundedBitmapDrawableFactory
热门推荐
10 广西考试祝福语结婚简短
11 猪年祝福语简短小孩
12 元旦祝福语送长辈简短
13 恭喜二宝祝福语简短
14 祝福语暖心话简短
15 国庆中秋祝福语简短兄弟
16 朋友订婚的祝福语简短
17 送弟弟中秋祝福语简短
18 爱生日祝福语简短独特