Android : My Button Image Is Enlarged In The App?
Where px
is the final image size in pixels, dp
is the desired size in density-independent units, and dpi
is the target density.
Simplifying this formula, using the size in pixels of your mdpi
images as the baseline:
ldpi = mdpi * 0.75hdpi = mdpi * 1.5xhdpi = mdpi * 2.0
Going back to your sample code, if you want a button that is 30dp by 30dp, you should be providing images for each density:
- ldpi: 23px x 23px
- mdpi: 30px x 30px
- hdpi: 45px x 45px
- xhdpi: 60px x 60px
Solution 2:
I think that may be folder issue. Where have you put the image file? (possibly there would not be a problem if You have it in drawable-hdpi
)
EDIT
ps - there is also a dp unit thing, which is pixel-independent.
Solution 3:
you are using the background property, android will stretch your image depending on the device resoulution in dpi (ldpi, mdpi, hdpi and xhdpi screens), if you put your image in drawable-mdpi folder, your image will stretch according to this coefficient
Post a Comment for "Android : My Button Image Is Enlarged In The App?"