• 安卓高级Fresco图片框架的时候


    Fresco:2015FaceBook推出的 及其强大
    支持webp图片格式
    和渐进式图片加载

    中文文档

    使用方法

    1. 引入依赖
      点击查看具体教程

    2. 基本使用步骤

      1. 在布局中使用其标签 <com.facebook.drawee.view.SimpleDraweeView/>
        注意不能使用包裹内容
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    
        xmlns:fresco="http://schemas.android.com/apk/res-auto"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.administrator.myapplication.MainActivity">
    
        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/my_image_view"
            android:layout_width="200dp"
            android:layout_height="200dp"
            fresco:placeholderImage="@mipmap/ic_launcher"
            />
    </RelativeLayout>
    

    注意需要初始化:

    public class Myappaliction extends Application{
    
        @Override
        public void onCreate() {
            super.onCreate();
    
            Fresco.initialize(this);
        }
    }
    package com.example.administrator.myapplication;
    
    import android.net.Uri;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    
    import com.facebook.drawee.backends.pipeline.Fresco;
    import com.facebook.drawee.interfaces.DraweeController;
    import com.facebook.drawee.view.SimpleDraweeView;
    import com.facebook.imagepipeline.request.ImageRequest;
    import com.facebook.imagepipeline.request.ImageRequestBuilder;
    
    public class MainActivity extends AppCompatActivity {
        private SimpleDraweeView show_iv;
        private String   path = "http://img.hb.aicdn.com/761f1bce319b745e663fed957606b4b5d167b9bff70a-nfBc9N_fw580";
        private  String  gifPath = "http://img.zcool.cn/community/012f4d5542e7de0000019ae98b8ef1.jpg";
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Uri uri = Uri.parse(gifPath);
            //以下方法使用渐进式并直接播放动态图
            show_iv=(SimpleDraweeView) findViewById(R.id.my_image_view);
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
                    .setProgressiveRenderingEnabled(true)
    
                    .build();
            DraweeController controller = Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
    
                    .setAutoPlayAnimations(true)//
                    .setOldController(show_iv.getController())
                    .build();
            show_iv.setController(controller);
    
    
    
    
        }
    }
    
  • 相关阅读:
    DedeCMS图集上传图片报错,FILEID:X 错误处理办法
    AE10.0打开MxD或shp文件时提示“The specified path is invalid”
    未能加载AE的ESRI.ArcGIS.3Danalyst.dll等程序集
    Intel Parallel Studio 2011: error2350 FDI server error
    Android Google Map APIKey申请
    关于程序堆栈的解释
    Major and Minor Numbers (主次设备号)这个听说过
    linux字符设备驱动之LED
    linux下ioctl函数学习
    Some Important Data Structures
  • 原文地址:https://www.cnblogs.com/muyuge/p/6152110.html
Copyright © 2020-2023  润新知