I'm downloading pictures from server, but pictures are not same (their resolution), so I want to hardsize them to picture from error() method (it's 50x50 px). But when I tested this code
Picasso.with(context)
.load(url)
.error(R.drawable.non_pic)
.resize(100, 100)
.into(holder.user_icon);
I noticed, that on my Meizu Pro 6 (diag = 5.2, PPI = 424, 1920x1080) and on emulator, based on Nexus 4 (diag = 4.7, 1280×768) there are different sizes of images after resize(). On Meizu image is very small, but on emulator it has same size with picture from error() (and it's strange for me, cause non_pic is png file with 50x50 pixels resolution). So, how can I get hardset image size with same for non_pic parameters?
It's because you are using px as measurement. Try to use Dp/Dpi instead. Here is a method how you can convert px to DP
public static float convertPixelsToDp(float px, Context context){
Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
float dp = px / ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
return dp;
}
For more about px and dp see here