Fresco图片加载(三)

1,有弧度图片样式

fresco=加载自定义弧度图片样式。这就涉及到刚才介绍的DraweeHierarchy,其有一个属性是setRoundingParams(roundingParams); 参数就是图片的弧度,可以自己进行定义:

 /**
     * rounded corner params
     * fromCornersRadius(float radius)  设置圆角半径
     * fromCornersRadii(float[] radii) 分别设置左上角、右上角、左下角、右下角圆角半径
     * fromCornersRadii(float topLeft, float topRight, float bottomRight, float bottomLeft)  分别设置左上角、右上角、左下角、右下角圆角半径
     * setCornersRadius(float radius)  设置圆角半径
     * setCornersRadii(float[] radii) 分别设置左上角、右上角、左下角、右下角圆角半径
     * setCornersRadii(float topLeft, float topRight, float bottomRight, float bottomLeft)  分别设置左上角、右上角、左下角、右下角圆角半径
     */
 public static RoundingParams getRoundingParams() {
        RoundingParams roundingParams = RoundingParams.fromCornersRadius(30);
//    roundingParams.asCircle();//圆形
//    roundingParams.setBorder(color, width);//fresco:roundingBorderWidth="2dp"边框  fresco:roundingBorderColor="@color/border_color"
//    roundingParams.setCornersRadii(radii);//半径
//    roundingParams.setCornersRadii(topLeft, topRight, bottomRight, bottomLeft)//fresco:roundTopLeft="true" fresco:roundTopRight="false" fresco:roundBottomLeft="false" fresco:roundBottomRight="true"
//    roundingParams. setCornersRadius(radius);//fresco:roundedCornerRadius="1dp"圆角
//    roundingParams.setOverlayColor(overlayColor);//fresco:roundWithOverlayColor="@color/corner_color"
//    roundingParams.setRoundAsCircle(roundAsCircle);//圆
//    roundingParams.setRoundingMethod(roundingMethod);
//    fresco:progressBarAutoRotateInterval="1000"自动旋转间隔
        // 或用 fromCornersRadii 以及 asCircle 方法
        return roundingParams;
    }

如果图片是圆形就直接可以设置RoundingParams.asCircle();
以上roundingParams参数都是设置在DraweeHierarchy中,draweeHierarchy.setRoundingParams(roundingParams);这样就很方便加载多种样式的图片了。

2,图片解码

  public static ImageDecodeOptions getImageDecodeOptions() {
        ImageDecodeOptions decodeOptions = ImageDecodeOptions.newBuilder()
//            .setBackgroundColor(Color.TRANSPARENT)//图片的背景颜色
//            .setDecodeAllFrames(decodeAllFrames)//解码所有帧
//            .setDecodePreviewFrame(decodePreviewFrame)//解码预览框
//            .setForceOldAnimationCode(forceOldAnimationCode)//使用以前动画
//            .setFrom(options)//使用已经存在的图像解码
//            .setMinDecodeIntervalMs(intervalMs)//最小解码间隔(分位单位)
                .setUseLastFrameForPreview(true)//使用最后一帧进行预览
                .build();
        return decodeOptions;
    }

FrescoDemo

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值