fresco

依赖

implementation 'com.facebook.fresco:fresco:1.9.0'
// 支持 GIF 动图,需要添加
implementation 'com.facebook.fresco:animated-gif:1.9.0'

创建外部类继承Application 重写onCreate()方法

public class MyApp extends Application { 
    @Override     
    public void onCreate() {  
       super.onCreate(); 
        //设置磁盘缓存    
        DiskCacheConfig diskCacheConfig =  DiskCacheConfig.newBuilder(this)  
            .setBaseDirectoryName("images")          
            .setBaseDirectoryPath(Environment.getExternalStorageDirectory())     
            .build();         
        //设置磁盘缓存的配置,生成配置文件    
        ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)      
             .setMainDiskCacheConfig(diskCacheConfig)          
             .build();        
         Fresco.initialize(this, config); //不设置默认传一个参数既可    
     } 
}

布局

<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/my_imag"
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:progressBarImage="@drawable/jz"/>
XML属性                          意义
fadeDuration 淡入淡出动画持续时间(单位:毫秒ms)
actualImageScaleType 实际图像的缩放类型
placeholderImage 占位图
placeholderImageScaleType 占位图的缩放类型
progressBarImage 进度图
progressBarImageScaleType 进度图的缩放类型
progressBarAutoRotateInterval 进度图自动旋转间隔时间(单位:毫秒ms)
failureImage 失败图
failureImageScaleType 失败图的缩放类型
retryImage 重试图
retryImageScaleType 重试图的缩放类型
backgroundImage 背景图
overlayImage 叠加图
pressedStateOverlayImage 按压状态下所显示的叠加图
roundAsCircle 设置为圆形图
roundedCornerRadius 圆角半径
roundTopLeft 左上角是否为圆角
roundTopRight 右上角是否为圆角
roundBottomLeft 左下角是否为圆角
roundBottomRight 右下角是否为圆角
roundingBorderWidth 圆形或者圆角图边框的宽度
roundingBorderColor 圆形或者圆角图边框的颜色
roundWithOverlayColor 圆形或者圆角图底下的叠加颜色(只能设置颜色)
viewAspectRatio 控件纵横比
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值