Skip to content

Instantly share code, notes, and snippets.

@pavi2410
Last active September 29, 2019 16:55
Show Gist options
  • Save pavi2410/2088d9aa9a9c00383038f9472acf8844 to your computer and use it in GitHub Desktop.
Save pavi2410/2088d9aa9a9c00383038f9472acf8844 to your computer and use it in GitHub Desktop.
<LinearLayout>
<TextView
android:id="@+id/tv"
android:tag="child"
/>
<Button
android:tag="child"
/>
</LinearLayout>

Ideas for CSS support in Android

class MainActivity : Activity() {
override fun onCreate(b: Bundle) {
super.onCreate(b)
setContentView(R.layout.activity_main)
stylesheet style this
}
val stylesheet = StyleSheet {
id("tv") { // finds a view by its id
color = Color.RED
fontSize = 12.sp
}
tag("child") { // finds views by their tag
color = Color.BLUE
fontSize = 16.sp
}
any<TextView> { // finds any views of the specified type (defaults to View)
color = red
fontSize = 12.sp
}
any > tag("children") { // > is an operator overload
// props
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment