Reputation: 1222
All the examples I see are using the activity layout for the GUI, but from my understanding, working with fragments is the preferred method because you can customize the GUI for small or big screens.
When creating an activity in Android Studio 0.4.5, two layouts are created, one for the activity and one for a fragment for that activity. Should I just ignore the activity layout and do everything in the fragment?
TIA.
Upvotes: 2
Views: 1016
Reputation: 659
Use the activity layout for the components which you want to be uniform throughout the fragments which will be hosted by this activity. eg. AppBar, FAB etc.
Fragment layout components should be more specific to the purpose for which you are using the fragment. And ofcourse it is a best practice to keep the fragment as a reusable component.
Upvotes: 0
Reputation: 80020
Yes, that's the point. If you put as much of your UI as possible in the fragment, then you can reuse that fragment in different situations. You can use the activity layout to organize your fragments, with separate layouts for different screen dimensions as necessary.
Upvotes: 1