簡體   English   中英

如何使用畢加索庫僅從底部剪切圖像

[英]how to use Picasso library to cut the image from bottom only

我正在使用下面的代碼將圖像加載到 imageView 中。我只想從底部剪切圖像。 我怎么能用畢加索做到這一點嘗試中心裁剪和從頂部和底部剪切的圖像

  Picasso.with(getContext())
                    .load(imageUrl)
                    .fit()
                    .into(imageView);

使用變換,您可以根據重力裁剪圖像。

Picasso.with(mContext)
       .load(imageUrl)
       .transform(new CropTransformation(500,150),  CropTransformation.GravityHorizontal.CENTER, CropTransformation.GravityVertical.TOP))
       .into(imageView);

上面的代碼只會從底部剪切圖像。

您可以在此處獲取 CropTransformation 庫。

試試這個 .centerCrop(Gravity.TOP)

   Picasso.get()
                .load(GlobalApplication.BaseUrl +"/" + item.AD_THUMBNAIL)
                .resize(180, 145)
                .centerCrop(Gravity.TOP)
                .into(holder.imgAd);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM