I am working on a Layout having 14 Icons in a screen. I created 9-patch images for all icons and added them in corresponding folders: MDPI, HDPI, XHDPI,XXHDPI,XXXHDPI,it's working fine. I tested on a few devices, as we know images are added and selected to display accordingly "Screen Density" not "Screen Size".
I used ScreenLayout_Size_Mask to get actual Screen size category.(ScreenLayout_Size_SMALL, ScreenLayout_Size_NORMAL, ScreenLayout_Size_LARGE,ScreenLayout_Size_XLARGE) I am retrieving Screen Size and Density of the screen. For ref:Link
For Device:
Nexus7(1200 x 1920 px ~323 ppi):
ScreenLayout_Size_LARGE and Density is XHIGH
Samsung Galaxy Grand-2(720 x 1280 px ~280 ppi):
ScreenLayout_Size_NORMAL and Density is XHIGH.
Though there is a big difference in their "Screen Sizes" still their dpi's are same(XHIGH) so selected icon images for both device are of same density(XHDPI) only, which actually should not be done, as icons will be inflated of bigger size comparatively on small screen devices(Galaxy Grand-2) which seems messy.
According to android standards we can add image resources for multiple Screen Density only and not according to Screen size.
One option I got is set ImageView size in ratio with screen size, but there are 14 icons in layout,how can I get proper ratio size for all ImageViews?
Other approach I found is to do programmatically like this:
Get Actual Screen size using ScreenLayout_Size_Mask
Add different images with different name for (small,normal,large,xlarge).
Is there any proper way to do so ? Any help will be highly appreciated.