B
B
BlindShot962014-01-05 16:02:35
Android
BlindShot96, 2014-01-05 16:02:35

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:
MT%20Fragments%20Things%20-%20Dual%20Pan
On tablets the full size version is used, on smartphones the list should be hidden in the NavigationDrawer.
dllFa.png
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

2 answer(s)
V
Vyacheslav Krainov, 2014-01-05
@BlindShot96

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
}

O
Oleg Gamega, 2014-01-05
@gadfi

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 question

Ask a Question

731 491 924 answers to any question