Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
int bwidth = bitmap.getWidth();
int bHeight = bitmap.getHeight();
int width =getApplicationContext().getResources().getDisplayMetrics().widthPixels;
int height = width * bHeight / bwidth;
ImageView img1 = (ImageView)this.findViewById(R.id.image1);
ViewGroup.LayoutParams para1 = img1.getLayoutParams();
para1.height = height;
img1.setLayoutParams(para1);
int bwidth = bitmap.getWidth();
int bHeight = bitmap.getHeight();
int width =getApplicationContext().getResources().getDisplayMetrics().widthPixels;
int height = width * bHeight / bwidth;
ImageView img1 = (ImageView)this.findViewById(R.id.image1);
ViewGroup.LayoutParams para1 = img1.getLayoutParams();
para1.height = height;
img1.setLayoutParams(para1);