I am using the onCreateOptionsMenu method to create a toolbar with icons in the MainActivity of my app. I am testing on different screen sizes and pixel densities with Android Studio's emulator. The documentation states,
"Based on the density of the current screen, the system uses any density-specific resources from your app. If resources are not available in the correct density, the system loads the default resources and scales them up or down as needed."
I've tried putting all of my vector icons the default drawable directory, but the system does not scale them for different screen sizes or densities at all. Nor does onCreateOptionsMenu scale the height of the toolbar or the title text. Is it supposed to?
Because of this, I have also tried using different density buckets to address that problem. However, I'm running into an issue with greatly varying screen sizes sharing the same density bucket.
As an example, I'm testing on Pixel 3 (5.5" phone) and Pixel C (10" tablet). They are using the same density bucket (xhdpi) so if I use a 24dp x 24dp icon for the phone, then it looks way too small on the tablet. How do I work around this?
You can string together multiple qualifiers and create a custom bucket. So in addition to the drawable-xhdpi bucket I added a drawable-sw720dp-xhdpi bucket with larger icons for the 10" tablet. Now tablet displays the slightly larger icons while the phone still uses the standard bucket. The solution can be found in the comments of the selected answer in this post by @Theo. Unfortunately the documentation does not state that multiple qualifiers are supported.