Ideas for CSS support in Android
Last active
September 29, 2019 16:55
-
-
Save pavi2410/2088d9aa9a9c00383038f9472acf8844 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<LinearLayout> | |
<TextView | |
android:id="@+id/tv" | |
android:tag="child" | |
/> | |
<Button | |
android:tag="child" | |
/> | |
</LinearLayout> |
This file contains hidden or 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
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