How to set width and height of a View in DP through code not in XML ?

by Mansoor » Thu, 27 Jan 2011 13:47:47 GMT


Sponsored Links
 hi ,
i am creating a Image view  through code dynamically based on certain
condition as below:

ImageView t = new ImageView(mContext);
t.setLayoutParams(new LinearLayout.LayoutParams(390,
                                                                300));
the width and height is in PX i.e 390 PX and 300 PX

but i want to know how to set width and height in dp instead of px
programmatically . In xml we can do but i have no idea how to do it in
code
please help me .

Thanks
Mansoor V.M

-- 



Other Threads

1. [WTB] HD2 mantab murah meriah

Numpang jalumnya mod...

Butuh gadget HD2 utk oprekan dan dijadikan android
*Untuk teman yg kesurupan/keracunan

Mohon Japri Langsung
adinata_...@hotmail.com

Trims.

@ocumudo
Java,Symbian,WindowsPhone,android,IOS

-- 
===============
"

2. clicking a link on a website launches my application...

I would like to have a link on a website, such that when it is
clicked, it will launch my android application with specific
parameters.

is a ContentResolver the way to go about doing this?

any sample code, examples or tutorials on how to do this?

tia.

-- 

3. OOT:E-mail dari SMART - @smart.co.id

4. (Unknown) contact showing up after a modify

5. qualcomm snapdragoon does not boot

6. Driver Nexian Journey

7. Mod: Member ID-Android Tembus Angka 6000