nikib3ro
nikib3ro

Reputation: 20596

Getting Android screen size type during runtime (drawable-small, drawable-normal, etc)

As explained in Developer documentation Android supports setting different images for different sizes of the screen by putting them in separate folders (drawable-small, drawable-normal, drawable-large and drawable-xlarge).

Is it possible to get the "type" of the screen that Android is using to load the resources during runtime? I need to log this variable for error reporting and it would help a lot if I can tell which drawable type folder system is using (similarly to how I can tell if it is ldpi, mdpi, hdpi or xhdpi by querying getResources().getDisplayMetrics().density).

Upvotes: 2

Views: 961

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006664

Is it possible to get the "type" of the screen that Android is using to load the resources during runtime?

getResources().getConfiguration() gives you a Configuration object, and from there you can examine the screenLayout field. This tells you size, long/not-long, and direction (LTR or RTL).

Upvotes: 4

Related Questions