【问题标题】:Cropping an image fetched using Picasso?裁剪使用毕加索获取的图像?
【发布时间】:2020-06-27 09:59:37
【问题描述】:

我的适配器类中有以下代码 -

 override fun onBindViewHolder(vendorsHolder: VendorsHolder, i: Int) {
        val model = miniVendorModels[i]
        Picasso.get().load(model.bannerPicture).into(vendorsHolder.vendorImageView)
...
...
...

我从模特那里得到的照片对我来说太宽了。

如何将它们裁剪为我自己的尺寸?我想将其裁剪为它们开头的 50%(从左侧开始)并仅显示它们。

编辑 -

这是我的 XML -

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/vendors_row_item_root_layout"
    android:layout_width="152dp"
    android:layout_height="match_parent">

    <androidx.cardview.widget.CardView
        android:id="@+id/search_image_contact_cardview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        app:cardCornerRadius="8dp"
        tools:layout_height="160dp">

        <com.twoverte.views.CropImageView
            android:id="@+id/vendors_row_item_imageview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            tools:src="@drawable/kikiandggcover" />


    </androidx.cardview.widget.CardView>


</androidx.constraintlayout.widget.ConstraintLayout>

【问题讨论】:

    标签: android android-imageview crop picasso


    【解决方案1】:

    试试这个

    Picasso.get()
           .load(model.bannerPicture)
           .resize(imgWidth, imgHeight).centerInside()
           .into(vendorsHolder.vendorImageView);
    

    【讨论】:

    • 添加了我的 XML 文件
    猜你喜欢
    • 2020-08-30
    • 2019-10-18
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    • 2018-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    相关资源
    最近更新 更多