I have a Drawable only in the hdpi folder (and can't be in others).
In my custom view, I want to calculate the ImageView width, in onMeasure().
Code is :
myImage.getDrawable().getIntrinsicWidth(); But, depend on the device, the IntrinsicWidth is not the same and not egal to the real width.
This code :
Log.e(TAG, "icon width="+myImage.getWidth()+" // intrinsic width="+myImage.getDrawable().getIntrinsicWidth()); Print these results :
On Nexus 4 : 180 // 187
On Asus transformers : 320 // 187
On Samsung S4 : 270 // 280
So, is there a way to get IntrinsicWidth equal to real width ?
Maybe with density ?