summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorPhilip Milne <pmilne@google.com>2012-04-24 22:12:36 -0700
committerPhilip Milne <pmilne@google.com>2012-04-27 16:46:57 -0700
commit7a23b49a8ceb07d3fa12c45fd42cd16131fd746a (patch)
tree3d0ba87bbc84830260a01a34d0abb5c13d6dd4d3 /graphics/java
parentc887843b19c5a31bcd14e0b29b035d2a6e1e6149 (diff)
downloadframeworks_base-7a23b49a8ceb07d3fa12c45fd42cd16131fd746a.zip
frameworks_base-7a23b49a8ceb07d3fa12c45fd42cd16131fd746a.tar.gz
frameworks_base-7a23b49a8ceb07d3fa12c45fd42cd16131fd746a.tar.bz2
Fixes for optical bounds feature.
1. Make the feature opt-in (ViewGroup::layoutMode defaults to CLIP_BOUNDS) without inheritance. 2. Rename COMPONENT_BOUNDS to CLIP_BOUNDS. 3. Rename LAYOUT_BOUNDS to OPTICAL_BOUNDS. 4. Complete GridLayout implementation. 5. Change the default_gap between components to 8dp, to align with the Style Guide. Change-Id: I8d40dfc5f4ca469f6424eb3ff60d07bec56e3a9f
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/drawable/NinePatchDrawable.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index 006baa7..b68b267 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -56,6 +56,7 @@ public class NinePatchDrawable extends Drawable {
private NinePatchState mNinePatchState;
private NinePatch mNinePatch;
private Rect mPadding;
+ private Insets mLayoutInsets = Insets.NONE;
private Paint mPaint;
private boolean mMutated;
@@ -180,12 +181,21 @@ public class NinePatchDrawable extends Drawable {
}
}
+ private Insets scaleFromDensity(Insets insets, int sdensity, int tdensity) {
+ int left = Bitmap.scaleFromDensity(insets.left, sdensity, tdensity);
+ int top = Bitmap.scaleFromDensity(insets.top, sdensity, tdensity);
+ int right = Bitmap.scaleFromDensity(insets.right, sdensity, tdensity);
+ int bottom = Bitmap.scaleFromDensity(insets.bottom, sdensity, tdensity);
+ return Insets.of(left, top, right, bottom);
+ }
+
private void computeBitmapSize() {
final int sdensity = mNinePatch.getDensity();
final int tdensity = mTargetDensity;
if (sdensity == tdensity) {
mBitmapWidth = mNinePatch.getWidth();
mBitmapHeight = mNinePatch.getHeight();
+ mLayoutInsets = mNinePatchState.mLayoutInsets;
} else {
mBitmapWidth = Bitmap.scaleFromDensity(mNinePatch.getWidth(),
sdensity, tdensity);
@@ -202,6 +212,7 @@ public class NinePatchDrawable extends Drawable {
dest.right = Bitmap.scaleFromDensity(src.right, sdensity, tdensity);
dest.bottom = Bitmap.scaleFromDensity(src.bottom, sdensity, tdensity);
}
+ mLayoutInsets = scaleFromDensity(mNinePatchState.mLayoutInsets, sdensity, tdensity);
}
}
@@ -226,7 +237,7 @@ public class NinePatchDrawable extends Drawable {
*/
@Override
public Insets getLayoutInsets() {
- return mNinePatchState.mLayoutInsets;
+ return mLayoutInsets;
}
@Override