Fix wrong getIconBounds method inside BubbleTextView

Bug: 205065809
Test: screenshot on the bug

TL;DR;; created two variants depending on the layout direction

Change-Id: I9c5e74409c701b1f219ca450de0dca2291507045
This commit is contained in:
Hyunyoung Song
2021-11-03 23:16:53 -07:00
parent 3b5dddbce1
commit c2f024beb6
3 changed files with 39 additions and 12 deletions

View File

@@ -526,6 +526,18 @@ public final class Utilities {
return defaultValue;
}
/**
* Using the view's bounds and icon size, calculate where the icon bounds will
* be if it was positioned at the center of the view.
*/
public static void setRectToViewCenter(View iconView, int iconSize, Rect outBounds) {
int top = (iconView.getHeight() - iconSize) / 2;
int left = (iconView.getWidth() - iconSize) / 2;
int right = left + iconSize;
int bottom = top + iconSize;
outBounds.set(left, top, right, bottom);
}
/**
* Ensures that a value is within given bounds. Specifically:
* If value is less than lowerBound, return lowerBound; else if value is greater than upperBound,