[android-developers] How to set width and height of a View in DP through code not in XML ?

2011-01-26 Thread Mansoor
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

Re: [android-developers] How to set width and height of a View in DP through code not in XML ?

2011-01-26 Thread Xu Jiyong
http://developer.android.com/guide/practices/screens_support.html search 'Converting dp units to pixel units' on above page. On Thu, Jan 27, 2011 at 1:47 PM, Mansoor mansoor@wipro.com wrote: hi , i am creating a Image view through code dynamically based on certain condition as below: