【问题标题】:How to properly organize the resources in the res folder? [duplicate]如何正确组织 res 文件夹中的资源? [复制]
【发布时间】:2020-05-31 18:32:35
【问题描述】:

我在 android studio 中使用 Kotlin 创建了一个项目

我现在尝试在“res”区域整理我的文件。 在 drawable 中有很多 png 文件(我的应用中使用的图标), 以及很多自定义控件:xml 文件,使用 shape、solid、stoke...

当我尝试使用 "resource type" = drawable 创建一个新的资源目录时: 它不编译:“shape”“solid”等...在编译过程中不再被识别。 android studio 要求我把我所有的形状都放在 drawable 文件夹中,这开始变得一团糟。

如何在 res 区域添加多个文件夹。 我想在单独的文件夹中正确分离图标,xml 文件?

感谢您的帮助。

【问题讨论】:

标签: android resources


【解决方案1】:

很遗憾,Android 不允许您这样做,所有可绘制对象都必须在可绘制文件夹中 - 我们无法创建子目录 (Can the Android drawable directory contain subdirectories?)。

为了能够管理所有这些混乱,我建议在名称前加上可绘制类型,这样你就有:

icon_my_icon_name
shape_my_shape_name
solid_my_solid_name
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-13
    • 2018-03-11
    • 2013-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多