android - android - 毕加索 | 裁剪平方变换占用额外空间
问题描述
只是想在android的RecyclerView中创建一个像ui这样的网格。
所以在片段中,将布局管理器设置为 grid :
binding.rvGallery.layoutManager = GridLayoutManager(requireContext(), 3)
galleryAdapter = GalleryAdapter(this)
binding.rvGallery.adapter = galleryAdapter
在适配器内部,我正在使用Picasso
加载图像:
private val squareTransformation = CropSquareTransformation()
...
Picasso
.get()
.load(galleryItemList[position].name)
.transform(squareTransformation)
.into(holder.image)
这是我的相对项目 xml 布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_item_gallery_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/default_gallery_item_content_description" />
</LinearLayout>
这是布局,recycleview 所在的位置:
<?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"
tools:context=".ui.GalleryFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
结果如下:https ://www.youtube.com/watch?v=dXmfRfqc08g
- 从 0.00 到 0.19,它只是加载图像而没有任何转换
- 之后,它正在加载转换,但有一些额外的间距。我不想要那个。
解决方案
推荐阅读
- python - 在运行时更新 celery conf
- sql-server - 如何在 SQL Server 中对多列使用 HASHBYTES 函数
- html - 动态注入 HTML 的 Angular 6 指令
- javascript - 反应路由器位置不触发更新
- r - 如何在 eBayes 函数中定义自由度
- arrays - Bigquery 数组中的不同计数
- c# - OutOfMemoryException,我怀疑原因是 DbContext,但我不确定?
- openedge - 使用 Progress Openedge ABL (ChUI) 程序确定运行时间的最有效方法是什么?
- vba - 我的“Worksheet_SelectionChange”代码要求我在更新数据透视表之前再次选择每个单元格
- php - 我想使用带有 PDO 的 Consolibyte PHP QuickBooks 库