子文件夹在android studio中进行布局(sub folder for layout in android studio)

我为我的大学开发一个android项目。 我的布局文件夹太大了,我决定在布局文件夹中创建子文件夹。

我读了这个答案和问题,但这对我并不适用。

android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "example.google.com.widgetforlockscreen" minSdkVersion 8 targetSdkVersion 23 versionCode 1 versionName "1.0" } sourceSets { main { res.srcDirs = [ 'src/main/res/layouts/layouts_category2', 'src/main/res/layouts', 'src/main/res' ] } } }

但没有为我创造。

I developing an android project for my university. My layout folder is too big, and i decide to create sub folder in my layout folder.

I read this answer and question but this is not work for me.

android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "example.google.com.widgetforlockscreen" minSdkVersion 8 targetSdkVersion 23 versionCode 1 versionName "1.0" } sourceSets { main { res.srcDirs = [ 'src/main/res/layouts/layouts_category2', 'src/main/res/layouts', 'src/main/res' ] } } }

but nothing create for me.

最满意答案

Gradle不会为你创建任何目录。 您必须创建以下目录结构,

- res/layouts - layout - layout1.xml - layouts_category2 - layout - layout2.xml

像这样,我们可以使用Gradle合并多个资源文件夹的能力。 请注意,它不是Android功能。

Gradle won't create any directories for you. You have to create the following directory structure,

- res/layouts - layout - layout1.xml - layouts_category2 - layout - layout2.xml

Like this, we can use Gradle's ability to merge multiple resource folders. Note that it's not an Android feature.

更多推荐