给定一个使用了
目标是获取由主题设置的按钮文本颜色,而不受特定主题或应用程序声明资源的限制。可以使用
AppTheme
主题的上下文(如下所示),是否有可能在不引用R.style.MyButtonStyle
、R.style.AppTheme
或android.R.style.Theme_Light
的情况下以编程方式获得颜色#ff11cc00?目标是获取由主题设置的按钮文本颜色,而不受特定主题或应用程序声明资源的限制。可以使用
android.R.style.Widget_Button
和android.R.attr.textColor
。<style name="AppTheme" parent="Theme.Light">
<item name="android:buttonStyle">@style/MyButtonStyle</item>
</style>
<style name="MyButtonStyle" parent="android:style/Widget.Button">
<item name="android:textColor">#ff11cc00</item>
</style>
MyButtonStyle
或AppTheme
时,你的意思是什么? - Manveer Chawla