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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -