Can I include subfolders in the Android layout folder?

Asked 2 years ago, Updated 2 years ago, 71 views

Until now, storing all layout files in the layout folder has been easy to manage a small project. I feel the need for subfolders when the project is heavy and growing. For example,

layout
-- -- layout_personal
   -- -- personal_detail.xml
   -- -- personal_other.xml
--layout_address
  -- -- address1.xml
  -- -- address2.xml

Like this. Put the layout_personal and layout_address folders in the layout folder, and there is a personal-related layout and address-related layout in the layout folder, respectively. I'd like to keep a subfolder like this, what should I do?

android android-layout

2022-09-22 22:23

1 Answers

This is possible with a gradient. https://github.com/eskimoapps/ResourceNestingExample This is a demo project. Go and refer to it.

Go to the gradle file

sourceSets {
    main {
        res.srcDirs =
        [
                'src/main/res/layouts/layouts_category2',
                'src/main/res/layouts',
                'src/main/res'
        ]
    }
}

You can add the layout like this.


2022-09-22 22:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.