Can the Android layout folder contain subfolders?

前端 未结 20 2642
暗喜
暗喜 2020-11-22 03:10

Right now, I\'m storing every XML layout file inside the \'res/layout\' folder, so it is feasible and simple to manage small projects, but when there is a case of large and

20条回答
  •  再見小時候
    2020-11-22 03:47

    • Step 1: Right click on layout - show in explorer
    • Step 2: Open the layout folder and create the subfolders directly: layout_1, layout_2 ...
    • Step 3: open layout_1 create folder layout (note: mandatory name is layout), open layout_2 folder create layout subdirectory (note: mandatory name is layout) ...
    • Step 4: Copy the xml files into the layout subdirectories in layout_1 and layout_2
    • Step 5: Run the code in buid.grade (module app) and hit sync now:

    sourceSets {
        main {
            res.srcDirs =
                [
                    'src / main / res / layout / layout_1'
                    'src / main / res / layout / layout_2',
                    'src / main / res'
                ]
        }
    }
    
    • Step 6: Summary: All the steps above will only help clustering folders and display in 'project' mode, while 'android' mode will display as normal.
    • So I draw that maybe naming prefixes is as effective as clustering folders.

提交回复
热议问题