Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Picasso's resizeDimen() method take dp or pixels?

I am quite confused about resizing with Picasso. If I understand it correctly, we have to pass pixels to the resize method, so we manually have to convert them from dp to support different screen densities. But what does the resizeDimenmethod do? Does it take dimension in dp so we don't have to convert them manually anymore? How is that related to the fit method?

like image 342
Florian Walther Avatar asked Mar 08 '23 06:03

Florian Walther


1 Answers

  • resizeDimen use dimen resource (not dp nether px). Dimen resources looks like <dimen name="logo_width">96dp</dimen> and they are used like this : R.dimen.logo_width.
  • resize method use pixel
  • fit method will resize your source according to the target size (usually an ImageView)

Note : The conversion from any dimension units to pixels is made by an Android context (the context in Picasso.with(context)). Take a look at this method from Picasso source code and this method from Android source code to understand how conversion works.

like image 126
François Legrand Avatar answered Mar 24 '23 20:03

François Legrand