views:

42

answers:

1

Hi,

I'm using the following code :

ImageView i = new ImageView(mContext);

i.setImageResource(mImageIds[position]);

i.setScaleType(ImageView.ScaleType.FIT_XY);

       //pixels settings !!!

i.setLayoutParams(new Gallery.LayoutParams(200, 100));

but as you can see, it is setting the layout dimensions in pixels.

Does anybody know how to do the same thing but in "dip" ?

A: 

See http://developer.android.com/guide/practices/screens_support.html#screen-independence

On how to convert from dpi to pixels.

Cpt.Ohlund
thanks its look interesting to me but I dont understand the formula...Do you understand it ? can you give me an example on how to convert 100dip to pixel for example ?
Fabien
I found this solution that work perfectly : http://stackoverflow.com/questions/2238883/what-is-the-correct-way-to-specify-dimensions-in-dip-from-java-code
Fabien