图片加载框架之Gilde详细讲解(二)
来源:互联网 发布:淘宝图片锁有用么 编辑:程序博客网 时间:2024/06/04 17:50
gilde的使用案例:
1)基本使用
2)加载网络图片
Glide.with(this).load("http://img1.imgtn.bdimg.com/it/u=2615772929,948758168&fm=21&gp=0.jpg").into(ivGlide1);
3)加载资源文件
Glide.with(this).load(R.mipmap.ic_launcher).into(ivGlide2);
4)加载本地图片
String gifUrl = "http://b.hiphotos.baidu.com/zhidao/pic/item/faedab64034f78f066abccc57b310a55b3191c67.jpg";
Glide.with(this).load(gifUrl).placeholder(R.mipmap.ic_launcher).into(ivGlide4);
5)在家资源文件
Glide.with(this).load(R.drawable.loading).asGif().placeholder(R.mipmap.ic_launcher).into(ivGlide5);
6)加载本地
String gifPath = Environment.getExternalStorageDirectory()+"/meinv2.jpg";
File gifFile = new File(gifPath);
Glide.with(this).load(gifFile).placeholder(R.mipmap.ic_launcher).into(ivGlide6);
7)加载本地小视频和快照
String videoPath =Environment.getExternalStorageDirectory()+"/video.mp4";;
File videoFile = new File(videoPath);
Glide.with(this).load(Uri.fromFile(videoFile)).placeholder(R.mipmap.ic_launcher).into(ivGlide7);
8)设置缩略图比例,先加载缩略图,在加载原图
String urlPath="/storage/emulated/0/meinv1.jpg";
Glide.with(this).load(new File(urlPath)).thumbnail(0.1f).centerCrop().placeholder(R.mipmap.ic_launcher).into(ivGlide8);
9)线建立一个缩略图对象,先加载缩略图,在加载原图
DrawableRequestBuilder thumbnailRequest= Glide.with(this).load(new File(urlPath));
Glide.with(this).load(Uri.fromFile(videoFile)).thumbnail(thumbnailRequest).centerCrop().placeholder(R.mipmap.ic_launcher).into(ivGlide9);
2)recyclerView中加载图片
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include layout="@layout/titlebar"></include>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_glide"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
1)初始化recyclerview
GlideAdapter glideAdapter = new GlideAdapter(this);
rvGlide.setAdapter(glideAdapter);
rvGlide.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
(2)编写适配器
a)准备数据
b)加载图片
c)加载动画
githup项目地址:https://github.com/benyondall/atgui
阅读全文
3 0
- 图片加载框架之Gilde详细讲解(二)
- 图片加载框架之Gilde详细讲解(一)
- Gilde图片加载框架的使用
- AndroidFramework之Volley详细讲解加载网络图片(二)
- Gilde加载圆形图片
- Gilde加载图片
- 揭秘之从RecyclerView滑动监听到Gilde平滑加载图片
- 揭秘之从RecyclerView滑动监听到Gilde平滑加载图片
- 揭秘之从RecyclerView滑动监听到Gilde平滑加载图片
- Android,Gilde框架加载图片进内存。出现的Bitmap too large to be uploaded into a texture
- 使用Gilde加载图片时裁剪大小异常
- RecyclerView瀑布流的形式利用Gilde加载网络图片
- 视图的隐藏显示附加Gilde加载图片模版
- Gilde加载网络图片到TextView的DrawableTop
- 网络框架之Retrofit详细讲解《一》
- 详细讲解Android的图片下载框架UniversialImageLoader之磁盘缓存的扩展(二)
- 图片加载框架之Picasso
- 图片加载框架之Fresco
- Elasticsearch之es学习工作中遇到的坑(陆续更新)
- .drawerlayout侧滑
- AWK
- 匿名隐私保护总结
- Tornado-Django-Flask框架...
- 图片加载框架之Gilde详细讲解(二)
- -TEST Fin 2 for NOIP 最后准备(110-300)
- FireBug安装
- unity编辑器(二)----MenuItem的用法
- Java homework6
- CIA9 彩色弹珠(线段树+扫描线)
- 用C语言实现三子棋
- 能被2、3、4、5、6、7、8、9等数整除的数的特征
- hoj3269