diff options
author | Bjorn Bringert <bringert@android.com> | 2009-07-22 19:13:39 +0100 |
---|---|---|
committer | Bjorn Bringert <bringert@android.com> | 2009-07-22 19:13:39 +0100 |
commit | 8051172a285a4b5926186e40d1c7942a93c4eb15 (patch) | |
tree | 286aabb8eaeb8e21424472fb85d635195cbdc8e4 /core/java/android | |
parent | aa0e47cbd6ccada9d194f39e6b4372d2d3594b38 (diff) | |
download | frameworks_base-8051172a285a4b5926186e40d1c7942a93c4eb15.zip frameworks_base-8051172a285a4b5926186e40d1c7942a93c4eb15.tar.gz frameworks_base-8051172a285a4b5926186e40d1c7942a93c4eb15.tar.bz2 |
Work around StateListDrawable padding in search suggestions
Sometimes when searching, some of the suggestions had no left padding.
The left-hand side icons were flush with the left edge of the screen.
The problems was that setting a StateListDrawable as a background
will always set the padding of a View, because of a problem in
DrawableContainer.
DrawableContainer.DrawableContainerState.getConstantPadding()
will always return a Rect if mVariablePadding is false, which
makes DrawableContainer.getPadding() return true, which
causes View to change the padding.
As a workaround, we use setVariablePadding(true) on the background
that we create.
Fixes http://b/editIssue?id=1984813
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/app/SuggestionsAdapter.java | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java index 593b7b7..4cd35a4 100644 --- a/core/java/android/app/SuggestionsAdapter.java +++ b/core/java/android/app/SuggestionsAdapter.java @@ -27,6 +27,7 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.DrawableContainer; import android.graphics.drawable.StateListDrawable; import android.net.Uri; import android.os.Bundle; @@ -359,6 +360,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter { newBg.addState(new int[]{android.R.attr.state_selected}, transparent); newBg.addState(new int[]{android.R.attr.state_pressed}, transparent); newBg.addState(new int[]{}, background); + // Workaround for the fact that StateListDrawable.getPadding(Rect) always returns + // true, and thus sets the padding of any view that has it as a background. + ((DrawableContainer.DrawableContainerState) newBg.getConstantState()) + .setVariablePadding(true); mBackgroundsCache.put(backgroundColor, newBg.getConstantState()); return newBg; } |