LayerDrawable类的使用

时间:2020-12-29 01:11:34
Drawable[] layers = new Drawable[2];
layers[0] = resources.getDrawable(R.mipmap.ic_02);
layers[1] = resources.getDrawable(R.mipmap.ic_01);//这层会放在前面那层
LayerDrawable layerDrawable = new LayerDrawable(layers);
int dimensionPixelSize0 = 0;
int dimensionPixelSize = 9;
int dimensionPixelSize2 = 80;
int dimensionPixelSize3 = 51;
//实验知 Inset 有点像 图片在外围添加的尺寸
layerDrawable.setLayerInset(0, dimensionPixelSize0, dimensionPixelSize0, dimensionPixelSize0, dimensionPixelSize0);
layerDrawable.setLayerInset(1, 21, dimensionPixelSize, dimensionPixelSize, dimensionPixelSize);
// 设置图片的大小
layerDrawable.setLayerSize(0, dimensionPixelSize2, dimensionPixelSize2);
layerDrawable.setLayerSize(1, dimensionPixelSize3, dimensionPixelSize3);

LayerDrawable类的使用