有时候需要更改TextView的默认颜色,最近安卓10上面如果TextView自己没设置默认的颜色的话它是默认白色的,很容易造成看不清的问题。更改的话一个一个改太麻烦,下面直接几行代码全部搞定:
在应用的values/styles .xml中更改定义
自定义应用全部button控件的style:

代码:
<style name="ButtonStyle" parent="android:Widget.Button">
<item name="android:background">@drawable/selector_button_background</item>
<item name = "android:textColor">@drawable/selector_button_text_color</item>
<item name="android:padding">10dp</item>
</style>
这2个@drawable资源是我自己自定义写的,记得别复制进去了哦
如上讲解:style name 可以自己随意定义,item name为需要改变的style名称系统定义,item里面更改为自己需要设置的style。
设置好自己需要的style之后一定要记得在自己的Theme style里面更改定义设置进去:

代码:
<item name="buttonStyle">@style/ButtonStyle</item>
这里面的item name为系统的资源设置的,自己找找就可以找到了
自定义应用全部TextView控件的Style同上差不多:

代码:
<style name="TextViewStyle" parent="android:Widget.TextView">
<item name="android:textColor">#747474</item>
</style>

代码:
<item name="android:textViewStyle">@style/TextViewStyle</item>
一定要记得theme里面的item name的系统设置的name别弄错了,弄错了没效果的。
应用全局设置的控件style到此结束,觉得还不错的可以评论讨论或者点个赞,谢谢各位大佬!!!