zoukankan      html  css  js  c++  java
  • 安卓高级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);
    
    
    
    
        }
    }
    
  • 相关阅读:
    sqlserver 镜像 断开连接 正在恢复+主机服务器关机用备用镜像
    SQL SERVER 2005镜像配置(有无见证服务器都行)
    Terminal Service 终端链接
    SSL/TLS Diffie-Hellman Modulus <= 1024 位 (LogJam) 使用2048位或更高的Diffie-Hellman
    各国各种语言翻译
    Windows Server 2012上安装.NET Framework 3.5
    ALM11服务器IP变更相关配置修改
    转载:Linux下启动和关闭Weblogic(管理服务器+被管服务器)
    转载:AWR介绍使用
    安装QTP之后造成环境变量java冲突问题的解决方案
  • 原文地址:https://www.cnblogs.com/muyuge/p/6152110.html
Copyright © 2011-2022 走看看