java - How to set orientation dynamically based on devices? -


is possible dynamically setting portrait mode , landscape mode ? example, need make application workable in landscape , portrait mode large mdpi, large hdpi , xlarge

for other resolutions such normal hdpi,normal hdpi , other , need portrait mode.

can me in this?

yes possible force such things. can detect density of device , can load appropriate xml file.

you can detect density looking @ display metrics:

displaymetrics metrics = getresources().getdisplaymetrics(); 

then looking @ metrics.densitydpi. can load different resources accordingly.

int layoutid; switch(metrics.densitydpi) {  case displaymetrics.density_low:      layoutid = r.layout.lowthingy             break;  case displaymetrics.density_medium:      layoutd = r.layout.mediumthingy              break;  ... (for other densities) } setcontentview(layoutid); 

but because can this, doesn't mean should. , think not best approach. think should read documentation.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -