Android图片自适应屏幕高度,拒绝拉伸变形

   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);

你可能感兴趣的:(Android图片自适应屏幕高度,拒绝拉伸变形)