Reputation: 21759
I want to display .png image on TextView. Someone will use tablet, someone will use smartphone, how can I show an image proportional to the screen? Do I have to create different images and use in the code something like if(screen == smartphone) setView(Png1.png)
?
Upvotes: 0
Views: 267
Reputation: 6033
There are two important parameters which needs to taken cared when you are designing an app which
should run on multiple devices:
Size: Size of a device in android is not defined as a unique physical value but as a range.
These are: small, normal, large and xlarge.
Density: Density is also defined as a range.
These are: ldpi, mdpi, hdpi and xhdpi.
For handling size you need to use have multiple layouts, one for each category of the size and you need to use different dp value for the height and width of the views for each of the layout as the sizeof a small and a large device will not be same.
For handling density you need to using different drawables for different screen densities i.e you need to place different density drawables in different drawable folders.
Eg:
These are the resolutions for a particular drawable
The ratio for this variation of the resolution is 3:4:6:8(ldpi:mdpi:hdpi:xhdpi)
For further reading you can refer to this android developer's link:
http://developer.android.com/guide/practices/screens_support.html
Upvotes: 2