I have a set of ImageViews whose BackgroundResource and LayoutParams will be defined in a separate xml file. The height, width, marginleft and margintop are given in pixels. The values are in respect to a 1024x600 pixel resolution screen. The code i'm using
    ImageView ImgV= (ImageView)findViewById(R.id.ImgV_1);
    RelativeLayout.LayoutParams the_dimens = new RelativeLayout.LayoutParams(50,50);
    the_dimens.setMargins(800,50,0,0);
    ImgV.setBackgroundResource(R.drawable.bulbon);
    ImgV.setLayoutParams(the_dimens);
While the height and width seem to be rightly displayed in pixels, the margins are not. So how can I set the margin values to apply in pixels rather than whatever default units the below code takes. 
        the_dimens.setMargins(800,50,0,0);
The app is only for a 1024x600 device, so i'm not worried about resolution independent design. Thanks.
 
     
     
     
    