Kotlin DSL to create Android resource XML
implementation("dev.sasikanth:android-resource-poet:<latest-version>")
val xml: String = resourceXml {
string(name = "app_name") {
value = "Twine"
translatable = false
}
dimen(name = "ball_radius") {
value = "30dp"
}
}
// Write XML to file
val fileWriter: OutputStreamWriter = // configure file output stream
fileWriter.write(xml)
String
resourceXml {
string(name = "") {
value = "" // Required
translatable = false // Optional - Default true
}
}
String Array
resourceXml {
stringArray(name = "") {
items = arrayOf("") // Required
translatable = false // Optional - Default true
}
}
Plurals
resourceXml {
stringPlurals(name = "") {
translatable = false // Optional - Default true
item {
quantity = "" // Required
value = "" // Required
}
}
}
Boolean
resourceXml {
boolean(name = "") {
value = true // Optional - Default false
}
}
Color
resourceXml {
color(name = "") {
value = "" // Required
}
}
Dimen
resourceXml {
dimen(name = "") {
value = "" // Required
}
}
Integer
resourceXml {
integer(name = "") {
value = "" // Required
}
}
Integer Array
resourceXml {
integerArray(name = "") {
values = intArrayOf() // Required
}
}
Style
resourceXml {
style(name = "") {
parent = "" // Optional - Default empty
item {
name = "" // Required
value = "" // Required
}
}
}
Copyright 2023 Sasikanth Miriyampalli
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.