我有这个xml;
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/back" />
<item>
<shape>
<solid/>
<stroke android:width="1dip" android:color="#25786" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip"
android:right="0dip" android:bottom="0dip" />
</shape>
</item>
</layer-list>
现在我通过代码来做:
Drawable[] layers = new Drawable[2];
ShapeDrawable sd1 = new ShapeDrawable(new RectShape());
sd1.getPaint().setColor(0xFFFFFFFF);
sd1.getPaint().setStyle(Style.STROKE);
sd1.getPaint().setStrokeWidth(1);
layers[0] = sd1;
LayerDrawable composite = new LayerDrawable(layers);
但我无法对其进行<corners android:radius="10dip"/>
编码<item android:drawable="@drawable/back" />
怎么做?
编辑 1
Drawable[] layers = new Drawable[2];
ShapeDrawable sd1 = new ShapeDrawable(new RectShape());
sd1.getPaint().setColor(0xFFFFFFFF);
sd1.getPaint().setStyle(Style.STROKE);
sd1.getPaint().setStrokeWidth(1);
sd1.getPaint().setPathEffect(new CornerPathEffect(10));
layers[1] = sd1;
layers[0] = getResources().getDrawable(R.drawable.pie_chart_back);
LayerDrawable composite = new LayerDrawable(layers);