OiO.lk Blog Android Place reference grid over all ImageView
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

Exit mobile version