Drawable[] layers = new Drawable[2];
layers[0] = new ColorDrawable(primaryColor);
layers[1] = new ColorDrawable(0x7f000000);
LayerDrawable layerDrawable = new LayerDrawable(layers);
layerDrawable.setLayerInset(0, 0, 0, 0, 0);
layerDrawable.setLayerInset(1, 0, 0, 0, 0);
setBackground(layerDrawable);也能够用layer-list在xml中实现原文:http://www.cnblogs.com/brucemengbm/p/6918756.html