Shr*_*ain 11 android android-glide
我一直在努力寻找过去5个小时的答案.我将图像从google plus存储到本地文件夹,并使用Glide库将图像加载到imageview中.
文件uri是file:///storage/emulated/0/MyApp/ProfilePics/profile_user1.jpg
我正在使用下面的代码通过滑行加载图像:
Glide.with(ProfileActivity.this).load(Uri.fromFile(new File(sharedPrefMan.getImageUrl()))).placeholder(R.drawable.placeholder_profile).into(imgProfilePic);
Run Code Online (Sandbox Code Playgroud)
其中sharedPrefMan.getImageUrl()返回/storage/emulated/0/MyApp/ProfilePics/profile_user1.jpg
图像存在于给定位置.
Moh*_*har 32
如果你有原始的图像路径,你必须转换为URI并显示这样的图像
String fileName = "1.jpg";
String completePath = Environment.getExternalStorageDirectory() + "/" + fileName;
File file = new File(completePath);
Uri imageUri = Uri.fromFile(file);
Glide.with(this)
.load(imageUri)
.into(imgView);
Run Code Online (Sandbox Code Playgroud)
看起来你拥有的URI比你只需要URI而不是URI
Glide.with(this)
.load(Uri)
.into(imgView);
Run Code Online (Sandbox Code Playgroud)
我正在使用这个版本
实现'com.github.bumptech.glide:glide:4.8.0'
你必须传递图像uri,如下所示:
Glide.with(this)
.load(Uri.fromFile(new File(imageStoragePath)))
.apply(new RequestOptions().override(100, 100))
.into(imageView);
Run Code Online (Sandbox Code Playgroud)
只需使用以下行:-
Glide.with(context).load(uri).transform(new Transform()).into(view)
Run Code Online (Sandbox Code Playgroud)
要获取 uri,请使用以下代码:-
Uri.fromFile(new File(Yourpath));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26134 次 |
| 最近记录: |