Android url设置setBackground

使用Glide从URL加载图像,Glide是一个快速高效的开源Android媒体管理和图像加载框架,将媒体解码,内存和磁盘缓存以及资源池整合到一个简单易用的界面中。

Glide负责尽可能平滑地滚动任何图像列表,并接收,调整大小和显示远程图像。

添加下面的依赖关系build.gradle

dependencies { 
    compile 'com.github.bumptech.glide:glide:3.6.0' 
    compile 'com.android.support:support-v4:19.1.0' 
} 

如用法:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    ... 

    ImageView imageView = (ImageView) findViewById(R.id.my_image_view); 

    Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView); 
} 

load方法只需传递图像的URL,并在into只是通过视图,在你的情况下currentview。 对于您的场景:

Glide.with(this).load("http://goo.gl/gEgYUd").into(currentView); 

猜你喜欢

转载自blog.csdn.net/qq_41954585/article/details/128353284