Compensate for Android launcher icon scaling #424
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #410
The launcher images created by
capacitor-assets generate
are correct, but the Android platform itself is displaying them scaled and cropped. We can compensate for that by defining an inset in the launcher XML.Credit for this approach goes to: https://stackoverflow.com/questions/66593626/why-does-adaptive-icon-generated-by-android-studio-crop-images-so-much-to-make-u
The workaround that twoco pointed out on the linked issue involves adding padding to the icon so that the desired icon size was 2/3 of the actual width. Using those numbers, I added a padding of ~1/6 to each edge, so ~1/3 in total for each dimension.
I tested this in android studio. I saw that the icon was fully visible in the launcher. I also tried it with background image that had circles touching the image edges, and I confirmed that they were not visible before this change and were visible at the edge of the image after this change.