相关疑难解决方法(0)

以编程方式获取颜色值(主题)

考虑一下:

styles.xml

<style name="BlueTheme" parent="@android:style/Theme.Black.NoTitleBar">
    <item name="theme_color">@color/theme_color_blue</item>
</style>
Run Code Online (Sandbox Code Playgroud)

attrs.xml

<attr name="theme_color" format="reference" />
Run Code Online (Sandbox Code Playgroud)

color.xml

<color name="theme_color_blue">#ff0071d3</color>
Run Code Online (Sandbox Code Playgroud)

所以主题颜色由主题引用.如何以编程方式获取theme_color(引用)?通常我会使用getResources().getColor()但不是在这种情况下,因为它被引用!

android android-theme android-resources

93
推荐指数
6
解决办法
5万
查看次数

标签 统计

android ×1

android-resources ×1

android-theme ×1