zoukankan      html  css  js  c++  java
  • 【Android Studio安装部署系列】十六、Android studio在layout目录下新建子目录

    版权声明:本文为HaiyuKing原创文章,转载请注明出处!

    概述

    一般用于分类显示不同模块的layout布局文件。

    在res/layout文件夹下创建子目录

    res/layout鼠标右键——New——Directory

    在创建好的子目录下,创建layout文件夹

    res/layout/home鼠标右键——New——Directory

    将布局文件放入相应的layout文件夹

     

    打开app/build.gradle,在android{}中加入以下代码

    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文件分组插件

  • 相关阅读:
    第十六周总结
    第十五周学习进度
    输出最长字符串链
    第二阶段冲刺10
    第二阶段冲刺09
    第二阶段冲刺08
    输入法评价
    第十四周进度总结
    collections模块
    shutil模块(了解)
  • 原文地址:https://www.cnblogs.com/whycxb/p/9095860.html
Copyright © 2011-2022 走看看