博客
关于我
android res资源文件分包
阅读量:236 次
发布时间:2019-03-01

本文共 483 字,大约阅读时间需要 1 分钟。

在Android开发中,资源文件的管理是开发者需要经常处理的内容。假设你在项目中需要将布局文件分成不同的活动目录,那么Gradle配置是必不可少的一步。

在app的build.gradle文件中,修改sourceSets部分如下:

sourceSets {    main {        res.srcDirs = ['src/main/res', 'src/main/res/layout/activity']    }}

接下来,在res目录下创建activity层级目录,将布局文件放入该目录。建议目录结构如下:

src/    main/        res/            activity/                layout/                    activity_layout.xml

这样配置后,开发者可以方便地在不同的活动中使用对应的布局文件。记得不要将drawable等其他目录放入activity目录中,以避免文件混乱。

这种方法虽然需要多层目录,但能够让文件分类更清晰,避免了手动输入冗长路径的麻烦。

转载地址:http://bhft.baihongyu.com/

你可能感兴趣的文章
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
no1
查看>>
NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
查看>>
NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
查看>>
Node JS: < 一> 初识Node JS
查看>>