Last active
May 24, 2022 20:52
-
-
Save cbedoy/5981fa6e7a5f32542a51ab7778d289de to your computer and use it in GitHub Desktop.
Dimens and Font size generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Made by cbedoy | |
*/ | |
val dimenRatio = mapOf( | |
"mdp" to .8F, "hdp" to .9f, "xhdp" to 1f, "xxhdp" to 1.1f, "xxxhdp" to 1.2f | |
) | |
fun generate(n: Int) { | |
dimenRatio.map { | |
val dimensList = mutableListOf<String>() | |
for (dm in 1..n) { | |
dimensList.add("<dimen name=\"dimen_${dm}_dp\">${String.format("%.0f", dm * it.value)}dp</dimen>") | |
} | |
println("Dimens for ${it.key} are:") | |
println(dimensList.joinToString("\n")) | |
} | |
} | |
fun generateFonts() { | |
val fontList = mutableListOf<String>() | |
for (dm in 1..100) { // It's almost impossible have more than 100 sp though | |
fontList.add("<dimen name=\"text_size_${dm}\">${dm}sp</dimen>") | |
} | |
println("Fonts are:") | |
println(fontList.joinToString("\n")) | |
} | |
fun main() { | |
generate(100) | |
generateFonts() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment