版权声明:本文为博主原创文章,未经博主允许不得转载。
一般用于分类显示不同模块的layout布局文件。
res/layout鼠标右键——New——Directory
res/layout/home鼠标右键——New——Directory
apply plugin: ‘com.android.application‘
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.why.project.helloworld"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
}
}
//在layout文件夹下建立子文件夹
sourceSets {
main{
res.srcDirs = [
‘src/main/res/layout/home‘,
‘src/main/res/layout‘,
‘src/main/res‘
]
}
}
}
dependencies {
implementation fileTree(include: [‘*.jar‘], dir: ‘libs‘)
implementation ‘com.android.support:appcompat-v7:27.1.1‘
implementation ‘com.android.support.constraint:constraint-layout:1.1.0‘
testImplementation ‘junit:junit:4.12‘
androidTestImplementation ‘com.android.support.test:runner:1.0.2‘
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2‘
implementation project(‘:baselibrary‘)
}
注意:每新建一个子目录,就需要添加一行类似‘src/main/res/layout/home‘,的代码。
至此,添加完成。
Android Studio分类整理res/Layout中的布局文件(创建子目录)
Android中layout建立子文件夹用来放置不同种类布局
Android Studio 在layout文件夹下建立子文件夹
【Android Studio安装部署系列】十六、Android studio在layout目录下新建子目录
原文:https://www.cnblogs.com/whycxb/p/9095860.html