learner
learner

Reputation: 1155

Android Phone and Tablet UI

I have made one app which is working fine for both Tablets and Phones. But as we know we should have a different layout for tablets( such as bigger font and images etc).

My question is how to provide the layouts such that they are only picked by tablets and not phones.

Example: If i provide xhdpi or hdpi layout thinking of these as tablet then it may be picked by some device also which is using this same configuration.

So how to be sure that a current device is tablet or phone and provide a specific layout for it?

Upvotes: 1

Views: 1266

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006964

My question is how to provide the layouts such that they are only picked by tablets and not phones.

Either use the classic screen size buckets (e.g., res/layout-large/) or come up with your own buckets using -swNNNdp (e.g., res/layout-sw600dp/ for resources to be used on devices whose shortest width is 600dp or higher).

This is explained in the documentation here, here, here, and perhaps a few other spots as well.

Example: If i provide xhdpi or hdpi layout thinking of these as tablet then it may be picked by some device also which is using this same configuration.

-xhdpi and -hdpi are screen densities and have nothing directly to do with screen size.

Upvotes: 1

Related Questions