xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:orientation="vertical"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.bw.fresco.MainActivity">
android:layout_width="200dp"
android:layout_marginTop="20dp"
android:layout_height="100dp"
android:id="@+id/sdv"
/>
android:layout_width="200dp"
android:layout_height="100dp"
android:id="@+id/p"
/>
android:layout_width="200dp"
android:layout_height="100dp"
android:id="@+id/g"
/>
public class MainActivity extends AppCompatActivity {
private SimpleDraweeView mSdv;
private ImageView mP;
String qqq="http://c.hiphotos.baidu.com/zhidao/wh=450,600/sign=d068ffe77cf40ad115b1cfe7621c3de9/b7fd5266d0160924710b6ac4d30735fae7cd34c7.jpg";
private ImageView mG;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
mSdv = (SimpleDraweeView) findViewById(R.id.sdv);
Uri parse = Uri.parse(qqq);
mSdv.setImageURI(parse);
Picasso.with(this).load(qqq).into(mP);
Glide.with(this).load(qqq).into(mG);
}
private void initView() {
mSdv = (SimpleDraweeView) findViewById(R.id.sdv);
mP = (ImageView) findViewById(R.id.p);
mG = (ImageView) findViewById(R.id.g);
}
}
//fresco需要初始化新写一个类
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
}
}
// Fresco依赖
compile 'com.facebook.fresco:fresco:0.9.0'
compile 'com.facebook.fresco:animated-gif:0.12.0'
// Picasso和Glide需要添加依赖
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.squareup.picasso:picasso:2.5.2'