diff options
author | Alan Viverette <alanv@google.com> | 2014-08-07 18:04:33 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-08-08 01:06:26 +0000 |
commit | 4afbbfd54739e879e28ef3919a4fef82e6c523ad (patch) | |
tree | 6192deb30dc8183f6d72614c79a9d70b2a7bc9ce /graphics | |
parent | 75e3ad631c922341dee6200145f8a627a6adbead (diff) | |
download | frameworks_base-4afbbfd54739e879e28ef3919a4fef82e6c523ad.zip frameworks_base-4afbbfd54739e879e28ef3919a4fef82e6c523ad.tar.gz frameworks_base-4afbbfd54739e879e28ef3919a4fef82e6c523ad.tar.bz2 |
Add insets to dialog background
Also adds inset attribute to InsetDrawable to control all four insets.
BUG: 16868069
Change-Id: I909d05a6dc69747e9092e9ac34551b18d70d2b9f
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/InsetDrawable.java | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/graphics/java/android/graphics/drawable/InsetDrawable.java b/graphics/java/android/graphics/drawable/InsetDrawable.java index ee5fe2e..588e776 100644 --- a/graphics/java/android/graphics/drawable/InsetDrawable.java +++ b/graphics/java/android/graphics/drawable/InsetDrawable.java @@ -119,20 +119,40 @@ public class InsetDrawable extends Drawable implements Drawable.Callback { // Extract the theme attributes, if any. state.mThemeAttrs = a.extractThemeAttrs(); - final Drawable dr = a.getDrawable(R.styleable.InsetDrawable_drawable); - if (dr != null) { - state.mDrawable = dr; - dr.setCallback(this); + final int N = a.getIndexCount(); + for (int i = 0; i < N; i++) { + final int attr = a.getIndex(i); + switch (attr) { + case R.styleable.InsetDrawable_drawable: + final Drawable dr = a.getDrawable(attr); + if (dr != null) { + state.mDrawable = dr; + dr.setCallback(this); + } + break; + case R.styleable.InsetDrawable_inset: + final int inset = a.getDimensionPixelOffset(attr, Integer.MIN_VALUE); + if (inset != Integer.MIN_VALUE) { + state.mInsetLeft = inset; + state.mInsetTop = inset; + state.mInsetRight = inset; + state.mInsetBottom = inset; + } + break; + case R.styleable.InsetDrawable_insetLeft: + state.mInsetLeft = a.getDimensionPixelOffset(attr, state.mInsetLeft); + break; + case R.styleable.InsetDrawable_insetTop: + state.mInsetTop = a.getDimensionPixelOffset(attr, state.mInsetTop); + break; + case R.styleable.InsetDrawable_insetRight: + state.mInsetRight = a.getDimensionPixelOffset(attr, state.mInsetRight); + break; + case R.styleable.InsetDrawable_insetBottom: + state.mInsetBottom = a.getDimensionPixelOffset(attr, state.mInsetBottom); + break; + } } - - state.mInsetLeft = a.getDimensionPixelOffset( - R.styleable.InsetDrawable_insetLeft, state.mInsetLeft); - state.mInsetTop = a.getDimensionPixelOffset( - R.styleable.InsetDrawable_insetTop, state.mInsetTop); - state.mInsetRight = a.getDimensionPixelOffset( - R.styleable.InsetDrawable_insetRight, state.mInsetRight); - state.mInsetBottom = a.getDimensionPixelOffset( - R.styleable.InsetDrawable_insetBottom, state.mInsetBottom); } @Override |