android create layer list with item and shape

‮ww‬w.lautturi.com
android create layer list with item and shape
GradientDrawable layer1 = new GradientDrawable();
GradientDrawable layer2 = new GradientDrawable();

layer1.setShape(GradientDrawable.OVAL);
layer1.setColor(Color.WHITE);
layer1.setStroke(3,Color.RED);
layer1.setSize(33,33);

layer2.setShape(GradientDrawable.OVAL);
layer2.setColor(Color.BLUE);
layer2.setStroke(2,Color.BLUE);

InsetDrawable insetLayer2 = new InsetDrawable(layer1, 8, 8, 8, 8);
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] {insetLayer2,layer2});

button.setBackground(layerDrawable);
Created Time:2017-08-30 18:16:02  Author:lautturi