Add dither XML attribute support to Gradient and ShapeDrawable.

Change-Id: I4b60a0ba6766b7e7b176e78dc7f15f8467e2b890
This commit is contained in:
Romain Guy
2011-02-23 15:57:08 -08:00
parent 39c512b623
commit ed7894352f
3 changed files with 80 additions and 5 deletions

View File

@@ -624,6 +624,8 @@ public class GradientDrawable extends Drawable {
int shapeType = a.getInt(
com.android.internal.R.styleable.GradientDrawable_shape, RECTANGLE);
boolean dither = a.getBoolean(
com.android.internal.R.styleable.GradientDrawable_dither, false);
if (shapeType == RING) {
st.mInnerRadius = a.getDimensionPixelSize(
@@ -645,10 +647,11 @@ public class GradientDrawable extends Drawable {
a.recycle();
setShape(shapeType);
setDither(dither);
int type;
final int innerDepth = parser.getDepth()+1;
final int innerDepth = parser.getDepth() + 1;
int depth;
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& ((depth=parser.getDepth()) >= innerDepth

View File

@@ -286,7 +286,7 @@ public class ShapeDrawable extends Drawable {
protected boolean inflateTag(String name, Resources r, XmlPullParser parser,
AttributeSet attrs) {
if (name.equals("padding")) {
if ("padding".equals(name)) {
TypedArray a = r.obtainAttributes(attrs,
com.android.internal.R.styleable.ShapeDrawablePadding);
setPadding(
@@ -315,7 +315,10 @@ public class ShapeDrawable extends Drawable {
int color = mShapeState.mPaint.getColor();
color = a.getColor(com.android.internal.R.styleable.ShapeDrawable_color, color);
mShapeState.mPaint.setColor(color);
boolean dither = a.getBoolean(com.android.internal.R.styleable.ShapeDrawable_dither, false);
mShapeState.mPaint.setDither(dither);
setIntrinsicWidth((int)
a.getDimension(com.android.internal.R.styleable.ShapeDrawable_width, 0f));
setIntrinsicHeight((int)