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

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -