Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compensate for Android launcher icon scaling #424

Merged
merged 1 commit into from
Nov 10, 2022

Conversation

noahbrenner
Copy link
Contributor

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.

Fixes ionic-team#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.
@muuvmuuv
Copy link
Contributor

Nice approach and would be easily adjustable for the people that needs that #118

@mlynch mlynch merged commit dae7898 into ionic-team:main Nov 10, 2022
@mlynch
Copy link
Contributor

mlynch commented Nov 10, 2022

Thanks, seems like a nice and simple approach. @muuvmuuv does this remove the need for #118 or should we keep talking about that one?

@noahbrenner
Copy link
Contributor Author

Yay, thanks for such a quick response! Any idea when this change might be released in a new version, @mlynch?

@muuvmuuv
Copy link
Contributor

Let's keep it as a draft @mlynch and wait for the commentators of #118 to test this one out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The app icon size appears too large.
3 participants