The task is to create a custom layout from the images. Created such a class that will resize images for a specific screen, without losing their quality. But now specific memory leaks. Who will tell?
public class ResizebleImageView extends ImageView { private Activity mActivity; private float mCoeficient; public ResizebleImageView(Context context, AttributeSet attrs) { super(context, attrs); mActivity = (Activity) context; mCoeficient = getCoeficient(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { System.out.println("Bytes per drawable " + ((BitmapDrawable)getDrawable()).getBitmap().getByteCount()); Drawable drawable = getDrawable(); if (drawable != null) { int width = MeasureSpec.getSize(widthMeasureSpec); int height; if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY) { height = MeasureSpec.getSize(heightMeasureSpec); } else { height = (int) Math.ceil((float) width * (float) drawable.getIntrinsicHeight() / (float) drawable.getIntrinsicWidth()); } setMeasuredDimension(width, height); } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } private float getCoeficient() { DisplayMetrics ds = new DisplayMetrics(); mActivity.getWindowManager().getDefaultDisplay().getMetrics(ds); int screenWidth = ds.widthPixels; return screenWidth / 750f; } public void configureView(int width, int height, int leftMargin, int topMargin) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) (width * mCoeficient), (int) (height * mCoeficient)); params.leftMargin = (int)(leftMargin * mCoeficient); params.topMargin = (int)(topMargin * mCoeficient); this.setLayoutParams(params); } }
Here is the method call from the activation of this class from the activation. images as you can see not so much, and their size becomes colossal.
sticks.configureView(459, 410, 106, 1610);/.ну и таких вызовов 7 штук для разных вьюх с разными размерами. 

