android - Picasso resize on different screens -
i'm downloading pictures server, pictures not same (their resolution), want hardsize them picture error() method (it's 50x50 px). when tested code
picasso.with(context) .load(url) .error(r.drawable.non_pic) .resize(100, 100) .into(holder.user_icon);
i noticed, on meizu pro 6 (diag = 5.2, ppi = 424, 1920x1080) , on emulator, based on nexus 4 (diag = 4.7, 1280×768) there different sizes of images after resize(). on meizu image small, on emulator has same size picture error() (and it's strange me, cause non_pic png file 50x50 pixels resolution). so, how can hardset image size same non_pic parameters?
it's because using px measurement. try use dp/dpi instead. here method how can convert px 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 px , dp see here
Comments
Post a Comment