我通过组合多个图像将一个放在另一个上使用 LayerDrawable 制作了一个图像
但最终的图像越来越紧张 这是我制作layerdrawable的代码Bitmap mainBitmap;
Resources r = getResources();
Drawable[] layers = new Drawable[10];
layers[0]=r.getDrawable(R.drawable.cloud);
layers[1] = r.getDrawable(fragment.resId1);
layers[2] = r.getDrawable(fragment.resId2);
layers[3] = r.getDrawable(fragment.resId3);
layers[4] = r.getDrawable(fragment.resId4);
layers[5] = r.getDrawable(fragment.resId5);
layers[6] = r.getDrawable(fragment.resId6);
layers[7] = r.getDrawable(fragment.resId7);
layers[8] = r.getDrawable(fragment.resId8);
layers[9] = r.getDrawable(fragment.resId9);
LayerDrawable layerDrawable = new LayerDrawable(layers);
int width = layerDrawable.getIntrinsicWidth();
int height = layerDrawable.getIntrinsicHeight();
mainBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(mainBitmap);
layerDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
layerDrawable.draw(canvas);</p>
and Here is the resultant image that i get through this code </p>
有没有人可以帮我缩短这个?