is there way check if user using tablet or phone? i've got problems tilt function , new tablet (transformer)
as has been mentioned before, not want check whether device tablet or phone want know features of device,
most of time, difference between tablet , phone screen size why want use different layout files. these files stored in res/layout-<qualifiers> directories. can create xml file in directoy res/values-<same qualifiers> each of layouts , put int/bool/string resource distinguish between layouts use.
example:
file res/values/screen.xml (assuming res/layout/ contains layout files handsets)
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="screen_type">phone</string> </resources>
file res/values-sw600dp/screen.xml (assuming res/layout-sw600dp/ contains layout files small tablets nexus 7)
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="screen_type">7-inch-tablet</string> </resources>
file res/values-sw720dp/screen.xml (assuming res/layout-sw720dp/ contains layout files large tablets nexus 10):
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="screen_type">10-inch-tablet</string> </resources> now screen type accessible via r.string.screen_type constant.
Comments
Post a Comment