Fresco图片框架的使用

1.导包

    compile 'com.facebook.fresco:fresco:0.12.0'
    compile 'com.facebook.fresco:imagepipeline-okhttp3:0.12.0+'



2.注册     就一句话可以写在主函数中    也可以写一个类继承Application    再到清单文件用name调用

Fresco.initialize(getApplicationContext());



3.在主布局中使用

这个是最简单的用法

<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/si"
        app:roundAsCircle="true"
        android:layout_width="85dp"
        android:layout_height="85dp" />



这个可以根据条件挑选想要的效果
<!--
        roundWithOverlayColor设置背景颜色
        roundAsCircle圆形
        app:retryImageScaleType="centerCrop"居中裁剪
        app:failureImage="@mipmap/ic_launcher_round"加载失败时展示的图片
        fadeDuration动画时间


    -->
    <com.facebook.drawee.view.SimpleDraweeView
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:id="@+id/main_sdv"
        app:backgroundImage="@android:color/holo_orange_light"
        app:fadeDuration="5000"
        app:failureImage="@mipmap/ic_launcher_round"
        app:placeholderImage="@mipmap/ic_launcher_round"
        app:placeholderImageScaleType="fitCenter"
        app:progressBarImage="@mipmap/ic_launcher_round"
        app:retryImage="@mipmap/ic_launcher_round"
        app:retryImageScaleType="centerCrop"
        app:roundAsCircle="true"
        app:roundWithOverlayColor="@color/colorBlue"
        app:roundingBorderColor="@color/colorAccent"
        app:roundingBorderWidth="3dp"
        />





4.给图片控件加载图片可以这样写

iv.setImageURI(arr.get(i).getPic());


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值