From b95c336d7863e6b63e2aa8682a90dd8ae213889c Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Fri, 17 Oct 2014 17:19:12 -0700 Subject: Translate compound button drawable by scroll position BUG: 18028674 Change-Id: Iaba848642b87f0d134c6a6c57e5756d883e45904 --- core/java/android/widget/CompoundButton.java | 10 +++++++++- core/res/res/layout/select_dialog_item_material.xml | 4 ++-- core/res/res/layout/select_dialog_multichoice_material.xml | 4 ++-- core/res/res/layout/select_dialog_singlechoice_material.xml | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index 2ccd18d..7d9d305 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -398,7 +398,15 @@ public abstract class CompoundButton extends Button implements Checkable { super.onDraw(canvas); if (buttonDrawable != null) { - buttonDrawable.draw(canvas); + final int scrollX = mScrollX; + final int scrollY = mScrollY; + if (scrollX == 0 && scrollY == 0) { + buttonDrawable.draw(canvas); + } else { + canvas.translate(scrollX, scrollY); + buttonDrawable.draw(canvas); + canvas.translate(-scrollX, -scrollY); + } } } diff --git a/core/res/res/layout/select_dialog_item_material.xml b/core/res/res/layout/select_dialog_item_material.xml index 59b432e..fe326f3 100644 --- a/core/res/res/layout/select_dialog_item_material.xml +++ b/core/res/res/layout/select_dialog_item_material.xml @@ -28,6 +28,6 @@ android:textAppearance="?android:attr/textAppearanceListItemSmall" android:textColor="?android:attr/textColorAlertDialogListItem" android:gravity="center_vertical" - android:paddingStart="16dip" - android:paddingEnd="16dip" + android:paddingStart="@dimen/alert_dialog_padding_material" + android:paddingEnd="@dimen/alert_dialog_padding_material" android:ellipsize="marquee" /> diff --git a/core/res/res/layout/select_dialog_multichoice_material.xml b/core/res/res/layout/select_dialog_multichoice_material.xml index 01e4cfa..e5b5b62 100644 --- a/core/res/res/layout/select_dialog_multichoice_material.xml +++ b/core/res/res/layout/select_dialog_multichoice_material.xml @@ -23,8 +23,8 @@ android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="?android:attr/textColorAlertDialogListItem" android:gravity="center_vertical" - android:paddingStart="16dip" - android:paddingEnd="16dip" + android:paddingStart="@dimen/alert_dialog_padding_material" + android:paddingEnd="@dimen/alert_dialog_padding_material" android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:checkMarkGravity="start" android:ellipsize="marquee" /> diff --git a/core/res/res/layout/select_dialog_singlechoice_material.xml b/core/res/res/layout/select_dialog_singlechoice_material.xml index 0f3c277..a9e603d 100644 --- a/core/res/res/layout/select_dialog_singlechoice_material.xml +++ b/core/res/res/layout/select_dialog_singlechoice_material.xml @@ -23,8 +23,8 @@ android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="?android:attr/textColorAlertDialogListItem" android:gravity="center_vertical" - android:paddingStart="16dip" - android:paddingEnd="16dip" + android:paddingStart="@dimen/alert_dialog_padding_material" + android:paddingEnd="@dimen/alert_dialog_padding_material" android:checkMark="?android:attr/listChoiceIndicatorSingle" android:checkMarkGravity="start" android:ellipsize="marquee" /> -- cgit v1.1