Merge "Use target size to scale down a widget preview image" into sc-v2-dev

This commit is contained in:
TreeHugger Robot 2021-08-10 19:01:45 +00:00 committed by Android (Google) Code Review
commit 26b25c222c
1 changed files with 3 additions and 3 deletions

View File

@ -325,10 +325,10 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
return;
}
if (drawable != null) {
float scale = 1f;
if (getWidth() > 0 && getHeight() > 0) {
// Scale down the preview size if it's wider than the cell.
float maxWidth = getWidth();
float scale = 1f;
if (mTargetPreviewWidth > 0) {
float maxWidth = mTargetPreviewWidth;
float previewWidth = drawable.getIntrinsicWidth() * mPreviewContainerScale;
scale = Math.min(maxWidth / previewWidth, 1);
}