android - How to find whether a phone is HDPI, XHDPI etc? -


my folder structure layouts "layout-sw600dp-hdpi", " layout-sw480dp-hdpi" , on.

at moment when want find out under category particular device falls in, adding layout file in every single folder different text. example if file in " layout-sw600dp-hdpi" folder, our text in layout file "layout-sw600dp-hdpi".

anyway our current method hard find device's size , make screen accordingly.

is there other better way of knowing this?

you can take here: getting screen density programmatically in android?

but... don't need answer.

if you're designing layout - should in way allows flexibility (just when you're designing web page). if have hard code value (ex. margin), can use dp units allow scale automatically. if it's not enough - can define dimension in resources: https://developer.android.com/samples/basicsyncadapter/res/values/dimen.html keep in mind resources can have same structure layouts - can put qualifiers resources-sw600 or use 1 of other options (android studio has special dialog allow creation of directories addressed different hardware / software configurations.

if it's still not enough - can use different layouts different configurations, or maybe @ fragments concept. https://developer.android.com/guide/components/fragments.html still - @ of points there no need know screen category (in terms of naming it).


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -