Remove drop target button drawable padding if text isn't hidden

Test: manual
Fix: 194320733
Change-Id: I12adeaf37cee5a0fcf383641f24b7750f14daf27
This commit is contained in:
Steven Ng
2021-07-23 17:06:10 +01:00
parent 643060d4fa
commit a1dcbce15a
3 changed files with 8 additions and 1 deletions

View File

@@ -66,6 +66,8 @@ public abstract class ButtonDropTarget extends TextView
private final int mDragDistanceThreshold;
/** The size of the drawable shown in the drop target. */
private final int mDrawableSize;
/** The padding, in pixels, between the text and drawable. */
private final int mDrawablePadding;
protected CharSequence mText;
protected Drawable mDrawable;
@@ -85,6 +87,8 @@ public abstract class ButtonDropTarget extends TextView
Resources resources = getResources();
mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
mDrawableSize = resources.getDimensionPixelSize(R.dimen.drop_target_text_size);
mDrawablePadding = resources.getDimensionPixelSize(
R.dimen.drop_target_button_drawable_padding);
}
@Override
@@ -300,6 +304,8 @@ public abstract class ButtonDropTarget extends TextView
mTextVisible = isVisible;
setText(newText);
setCompoundDrawablesRelative(mDrawable, null, null, null);
int drawablePadding = mTextVisible ? mDrawablePadding : 0;
setCompoundDrawablePadding(drawablePadding);
}
}