Answer the question
In order to leave comments, you need to log in
How to develop Android applications for different screens?
Hello everyone) There was a task to rework an application written for tablets (7-10 inches) for smartphones. The main screen is a "master - detail" something like this:
On tablets the full size version is used, on smartphones the list should be hidden in the NavigationDrawer.
Everything is quite simple and already done separately.
Tell me, please, how to combine all this into one application, while not cluttering up the Activity class with a bunch of methods for different behavior? Is it possible to load different layouts and Activities depending on the screen size?
Answer the question
In order to leave comments, you need to log in
Make a separate layout for the main screen in the res/layout-large (7'') and res/layout-xlarge (10'') folders, where instead of a NavigationDrawer a regular LinearLayout with a ListView, give it an id (for example, tablet_menu ). In the Activity, check if this id is in the layout:
if (findViewById(R.id.tablet_menu) != null) {
// Отключаем NavigationDrawer
}
All this in fragments, depending on the situation, the desired fragment is called, as an example, you can simply create a project in eclipse or android studio that takes into account different sizes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question