Fresco 使用

Fresco 官网:http://fresco-cn.org/
fresco demo:https://github.com/liaohuqiu/fresco-demo-for-gradle
Fresco引起的在arm64位机器上找不到对应的so库:http://blog.csdn.net/it_talk/article/details/50835595

Fresco 使用

加载网络图片简单步骤

添加依赖

compile 'com.facebook.fresco:fresco:0.14.1'

在 Application 中初始化

[MyApplication.java]
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Fresco.initialize(this);
    }
}

在 xml 布局文件中,加入命名空间:

<!-- 其他元素-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fresco="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

加入 SimpleDraweeView

<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/my_image_view"
    android:layout_width="130dp"
    android:layout_height="130dp"
    fresco:placeholderImage="@drawable/my_drawable"
  />

开始加载图片

Uri uri = Uri.parse("https://raw.githubusercontent.com/facebook/fresco/gh-pages/static/logo.png");
SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.my_image_view);
draweeView.setImageURI(uri);

加载本地图片

适用于 Fresco 的绝对 url

raw 路径示例:

"res://com.xxx.yy/"+R.raw.web_loading

正式打包时候遇到的问题

不同引用库里jar的重复引用。

Error:Execution failed for task ':qspLauncher:transformClassesAndResourcesWithProguardForOnlineRelease'.
> java.io.IOException: Can't write [D:\qsp_release\qspLauncher\build\intermediates\transforms\proguard\online\release\jars\3\1f\main.jar] (Can't read [D:\qsp_release\qspLauncher\build\intermediates\exploded-aar\com.android.support\support-core-utils\24.2.1\jars\libs\internal_impl-24.2.1.jar(;;;;;;**.class)] (Duplicate zip entry [internal_impl-24.2.1.jar:android/support/v4/graphics/drawable/RoundedBitmapDrawable.class]))

解决办法:
修改导入的fresco 的版本compile ('com.facebook.fresco:fresco:0.6.0+')








最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,995评论 25 709
  • 首届中华百家和鸣国学论坛 2012年6月28日-30日,以“信仰回归 塑国魂”为主题的首届中华百家和鸣国学论坛在北...
    百家和鸣阅读 3,860评论 0 0
  • 墙上莺啼, 惊起浮生半日闲。 驻足时光, 振翅过他檐。 忘却墙角幽兰, 相伴已三年。 此时桃花待彼时, 今日桃花只...
    猫尾上的荷包蛋阅读 4,889评论 4 6
  • 环境说明 1、win102、python3.6.0 排错流程 1、pip install scrapy2、报错,无...
    Joncle阅读 3,126评论 0 0

友情链接更多精彩内容