我无法将图像加载到ImageViewAsync中。图片应该在空白处。我已经尝试了同步和异步方法。我在mipmap文件夹中有图像placeholderProfileImage.png。我在调试器中浏览了绑定代码,所有这些似乎都井井有条。请注意,我删除了其他用文本填充视图的代码。那部分正在工作。我在图像方面做错了什么?
profilePhotoImageView在布局中定义:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/acquaintanceRow"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center">
<FFImageLoading.Views.ImageViewAsync
android:id="@+id/profilePhotoImageView"
android:scaleType="fitCenter"
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:transitionName="@string/profilePhotoTransition" />
>
视图持有人类包含ProfilePhotoImageView:
internal class MyViewHolder : RecyclerView.ViewHolder
{
// removed stuff for brevity
public ImageViewAsync ProfilePhotoImageView { get; }
public MyViewHolder(View itemView) : base(itemView)
{
MyRow = itemView;
// removed stuff for brevity
ProfilePhotoImageView = MyRow.FindViewById<ImageViewAsync>(Resource.Id.profilePhotoImageView);
}
}
绑定代码:
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
var viewHolder = holder as MyViewHolder;
string photoUrl = "placeholderProfileImage.png:";
FFImageLoading.Work.TaskParameter taskParameter = ImageService.LoadFileFromApplicationBundle(photoUrl);
FFImageLoading.Work.TaskParameter taskParameter2 = taskParameter.Transform(new CircleTransformation());
taskParameter2.Into(viewHolder.ProfilePhotoImageView);
// tried asynchronous as well, nothing
//FFImageLoading.Work.TaskParameter taskParameter = ImageService.LoadUrl(photoUrl);
//FFImageLoading.Work.TaskParameter taskParameter2 = taskParameter.Transform(new CircleTransformation());
//taskParameter2.Into(viewHolder.ProfilePhotoImageView);
}
LoadFileFromApplicationBundle
从Assets
不是mipmap文件夹加载文件。因此,您必须将文件移动到文件Assets
夹,并将构建操作设置为AndroidAsset
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句