Вопрос

I making an app for tablets. and want to use a PNG file for some of the buttons. What size the button must be? Based on Android size it should be at least 48dp x 48dp and with converters 48dp is different in different sizes of android devices. This is a calculator: Link

ldpi    @ 48.00dp   = 36.00px
mdpi    @ 48.00dp   = 48.00px
hdpi    @ 48.00dp   = 72.00px
xhdpi   @ 48.00dp   = 96.00px

So Should I make 4 different files for my png files with top pixels ? for example a version with 36px x 36px for the ldpi folder? or just make the biggest size like xhdpi (96px)?

Thanks in advance.

Это было полезно?

Решение

You CAN just make one large button size and get away with it, but thats not best practice.. You should have different sized images for different resolutions.

From Android: Although the system performs scaling and resizing to make your application work on different screens, you should make the effort to optimize your application for different screen sizes and densities. In doing so, you maximize the user experience for all devices and your users believe that your application was actually designed for their devices—rather than simply stretched to fit the screen on their devices.

More info on supporting different devices and best practices. Android Practices

Другие советы

Ya. Better Use 9 patch Images as the background for the buttons. So it will expand/ behave according screen size . Check this Link .

I just use the highest resolution and let Android scale it down. Doing it this way makes the download (file) size much, much smaller than having a different image for each resolution. And the quality as it's scaled down is no worse than it would be if you scaled it down yourself in MS Paint.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top