October 22, 2024
Chicago 12, Melborne City, USA
Android

Place reference grid over all ImageView


My app has a single ImageView in a LinearLayout. It currently places a photo in the ImageView preserving the photo’s aspect ratio by setting ScaleType.CENTER_INSIDE. This results, correctly, in a display with background color rectangles above or below (or left or right of) the photo.

Now, I’d like to place a reference grid over the entire ImageView area, that is, the photo plus the two background rectangles. The problem is determining the width, height of the total ImageArea to construct a grid Bitmap that will occupy the ImageView. I can construct a 1000 x 1000 Bitmap grid and place it in the ImageView with ScaleType.FIT_XY, but then can’t preserve the photo’s aspect ratio in adding it to that square Bitmap.

Ideally, I’d like to write a properly scaled grid OVER the existing photo.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video