fit() 및 resize()를 사용하면 이미지를 다운로드하기 전에 크기가 작아진다는 것을 알고 있습니다. 그러나 listView가 사용되고 이미지의 비율이 변하는 경우 imageView의 layout_width 및 layout_height를 wrap_content로 설정 한 다음 transform()을 사용하여 이미지 뷰를 이미지 뷰에 배치하기 전에 이미지의 비율을 결정해야합니다.이미지를 다운로드하기 전에 Picasso의 fit(), resize() 및 transform() 크기가 조정됩니까?
예 :
Picasso.with(mContext).load(region.getImage_url()).transform(new Transformation() {
@Override
public Bitmap transform(Bitmap source) {
int targetWidth = getContext().getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE).getInt(Constants.DEVICE_WIDTH, 0);
double aspectRatio = (double) source.getHeight()/(double) source.getWidth();
int targetHeight = (int) (holder.targetWidth * aspectRatio);
Bitmap result = Bitmap.createScaledBitmap(source, targetWidth, targetHeight, false);
if (result != source) {
// Same bitmap is returned if sizes are the same
source.recycle();
}
return result;
}
@Override
public String key() {
return "transformation" + " desiredWidth";
}
}).into(holder.imageView);
내 문제는 Picasso의 변형 방법도 이미지를 다운로드하기 전에 축소하는 것입니까? 그렇지 않다면, listview의 imageViews에 고정 비율을 설정하지 않으면 서 가장 좋은 접근 방법은 무엇입니까?
** 이미지를 다운로드하기 전에 ** 이미지 크기를 줄이시겠습니까? – Harry
네, 그게 내가 원하는거야. 또는 나는 어떤 실수를 했는가? 나는 주된 목표는 이미지의 로딩을 효율적으로 만드는 것이다. – Derekyy
아니요, 제가 말씀 드렸습니다. 효율적인 대역폭 사용을 위해 많은 노력을 기울였습니다. 도움이된다면 내 대답을 볼 수 있습니다. – Harry