Giter Site home page Giter Site logo

frescodemo's Introduction

Demo of Fresco

1、Fresco 加载图片

(1)在 build.gradle 中添加以下依赖:

 dependencies {
  compile 'com.facebook.fresco:fresco:0.5.0+'
}

(2)在AndroidManifest.xml 中 添加Internet 权限

<uses-permission android:name="android.permission.INTERNET"/>

(3)在应用调用 setContentView() 之前,初始化:

Fresco.initialize(MainActivity.this);
setContentView(R.layout.activity_main);

(4)在xml布局文件中,添加命名空间:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">



<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/my_image_view"
android:layout_width="300dp"
android:layout_height="400dp"
fresco:roundedCornerRadius="30dp"
fresco:actualImageScaleType="focusCrop"
/>
</RelativeLayout>

(5)使用SimpleDraweeView:

Fresco.initialize(MainActivity.this);
setContentView(R.layout.activity_main);

//DemoOne加载图片
SDrawView=(SimpleDraweeView)findViewById(R.id.my_image_view);
Uri uri = Uri.parse("https://www.baidu.com/img/bdlogo.png");
SDrawView.setImageURI(uri);

2、

frescodemo's People

Contributors

androidkaka avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.