0

I have application with many fragments, many layouts and many viewmodels. Moving around thru whole project tree when I'm working on FeatureFragment.kt feature_fragment_layout.xml and FeatureFragmentViewModel.kt is really annoying.

Can I change android project structure to get something similar to this?

FeatureA
    FeatureAFragment.kt
    FeatureAViewModel.kt
    feature_a_layout.xml
FeatureB
    FeatureBFragment.kt
    FeatureBViewModel.kt
    feature_B_layout.xml

Users
    UserDetailsFragment
    UsersListAdapter
    UsersFragment
    user_details_fragment.xml
    user_list_item_extended.xml
    user_list_item_simple.xml
    users_fragment.xml
    
Kamil
  • 13,363
  • 24
  • 88
  • 183
  • 1
    Modularization by feature. https://developer.android.com/topic/modularization?hl=en – laalto Oct 20 '22 at 16:25
  • 1
    Modularization will not help you and yes, this is one of the biggest pitfalls of Android.. You can not have the layout resources in the same folder as the source code. A good rule of thumb is to have a pattern/policy for the naming of Fragment/layout. Android Studio has a shortcut CTRL+SHIFT+N for searching a file name. – TheLibrarian Oct 20 '22 at 18:01
  • @laalto Thanks for interesting article with interesting link to example project repository. It can help to split project into pieces and can help teams a lot, but as TheLibrarian noticed the problem with "far" xml files remains. – Kamil Oct 20 '22 at 20:24
  • Is all this really hardcoded? There is no such thing like C makefile equivalent? – Kamil Oct 20 '22 at 20:42

0 Answers0