Add width and height set for Grid preview
Test: Manually
Bug: 155938545
Change-Id: Ibe957b09e812b8545c3c5c211610e50d09fbb1eb
diff --git a/src/com/android/customization/picker/grid/GridOptionPreviewer.java b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
index 993d873..cbe8ef2 100644
--- a/src/com/android/customization/picker/grid/GridOptionPreviewer.java
+++ b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
@@ -22,6 +22,7 @@
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -78,12 +79,12 @@
if (usesSurfaceView) {
mGridOptionSurface = new SurfaceView(mContext);
- mPreviewContainer.addView(mGridOptionSurface);
+ setUpView(mGridOptionSurface);
mGridOptionSurface.setZOrderOnTop(true);
mGridOptionSurface.getHolder().addCallback(mSurfaceCallback);
} else {
final ImageView previewImage = new ImageView(mContext);
- mPreviewContainer.addView(previewImage);
+ setUpView(previewImage);
final Asset previewAsset = new ContentUriAsset(
mContext,
mGridOption.previewImageUri,
@@ -97,6 +98,13 @@
}
}
+ private void setUpView(View view) {
+ view.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT));
+ mPreviewContainer.addView(view);
+ }
+
private final SurfaceHolder.Callback mSurfaceCallback = new SurfaceHolder.Callback() {
private Surface mLastSurface;
private Message mCallback;