summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/Workspace.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index c984ad65d..9800cf376 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1992,6 +1992,15 @@ public class Workspace extends SmoothPagedView
mDragOutline = createDragOutline(v, canvas, DRAG_BITMAP_PADDING);
}
+ private Rect getDrawableBounds(Drawable d) {
+ Rect bounds = new Rect();
+ d.copyBounds(bounds);
+ if (bounds.width() == 0 || bounds.height() == 0) {
+ bounds.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
+ }
+ return bounds;
+ }
+
public void onExternalDragStartedWithItem(View v) {
final Canvas canvas = new Canvas();
@@ -2006,8 +2015,9 @@ public class Workspace extends SmoothPagedView
if (v instanceof TextView) {
TextView tv = (TextView) v;
Drawable d = tv.getCompoundDrawables()[1];
- bmpWidth = d.getIntrinsicWidth();
- bmpHeight = d.getIntrinsicHeight();
+ Rect bounds = getDrawableBounds(d);
+ bmpWidth = bounds.width();
+ bmpHeight = bounds.height();
}
// Compose the bitmap to create the icon from
@@ -2527,7 +2537,8 @@ public class Workspace extends SmoothPagedView
destCanvas.save();
if (v instanceof TextView && pruneToDrawable) {
Drawable d = ((TextView) v).getCompoundDrawables()[1];
- clipRect.set(0, 0, d.getIntrinsicWidth() + padding, d.getIntrinsicHeight() + padding);
+ Rect bounds = getDrawableBounds(d);
+ clipRect.set(0, 0, bounds.width() + padding, bounds.height() + padding);
destCanvas.translate(padding / 2, padding / 2);
d.draw(destCanvas);
} else {
@@ -2568,8 +2579,9 @@ public class Workspace extends SmoothPagedView
if (v instanceof TextView) {
Drawable d = ((TextView) v).getCompoundDrawables()[1];
- b = Bitmap.createBitmap(d.getIntrinsicWidth() + padding,
- d.getIntrinsicHeight() + padding, Bitmap.Config.ARGB_8888);
+ Rect bounds = getDrawableBounds(d);
+ b = Bitmap.createBitmap(bounds.width() + padding,
+ bounds.height() + padding, Bitmap.Config.ARGB_8888);
} else {
b = Bitmap.createBitmap(
v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888);