【发布时间】:2020-07-18 16:44:32
【问题描述】:
所以在目前的andriod开发中,如果我们需要在主题中引用一个颜色集,我们可以简单地这样做:(在布局xml中)
....
<TextView
...
android:textColor="?attr/colorPrimary"
.../>
....
如果我在主题中设置蓝色。我会在上面的 textview 中得到那个颜色。
我想知道如何在Jetpack Compose 中做同样的事情。在Compose,我们这样做了,
MaterialTheme(...) {
Column {
Text(
...
textStyle = TextStyle(color = ????) // How to I reference to the theme?
)
}
}
【问题讨论】:
-
如果你使用的是 Material Design Components,你可以使用Accompanist to leverage your theme resource in Compose。
标签: android android-theme android-jetpack-compose