为什么图层可绘制图像会被拉伸使用多个图层进行绘制时

时间:2015-06-03 05:42:56

标签: android xml-drawable 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>

http://i.stack.imgur.com/Vuga9.jpg

  有没有人可以帮我做空?

0 个答案:

没有答案