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中实现
时间: 2024-10-17 11:51:31