博客
关于我
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 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
查看>>
Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime(72)
查看>>
Node-RED中使用JSON数据建立web网站
查看>>
Node-RED中使用json节点解析JSON数据
查看>>
Node-RED中使用node-random节点来实现随机数在折线图中显示
查看>>
Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
查看>>
Node-RED中使用node-red-contrib-image-output节点实现图片预览
查看>>
Node-RED中使用node-red-node-ui-iframe节点实现内嵌iframe访问其他网站的效果
查看>>
Node-RED中使用Notification元件显示警告讯息框(温度过高提示)
查看>>
Node-RED中实现HTML表单提交和获取提交的内容
查看>>
Node-RED中建立Websocket客户端连接
查看>>