如何将所有文本颜色更改为默认颜色(文本为黑色,提示为灰色)而不是白色
How to change all text colour to default colour (Black for Text, Grey for Hint) instead of white
目前我所有的文本和提示颜色默认都是白色的,虽然我可以在 xml
文件中更改它们,但某些东西如 TextInputLayout
文本计数器没有'允许颜色改变
下面是我的colors.xml
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#5CCDCC</color>
下面是我的styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/GreenishBlue</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
AndroidManifest
修改为:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomTheme">
文件 res/values/styles.xml
如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColor">#000</item> //black color for text
<item name="android:textColorHint">#939393</item> //Gray color for hint
</style>
</resources>
将以下代码添加到您现有的 AppTheme
将更改控件中的默认文本颜色,其中文本颜色未在 xml 中内联设置,使用不同的样式或动态。
<item name="android:textColor">#000000</item>
<item name="android:textColorHint">#666666</item>
目前我所有的文本和提示颜色默认都是白色的,虽然我可以在 xml
文件中更改它们,但某些东西如 TextInputLayout
文本计数器没有'允许颜色改变
下面是我的colors.xml
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#5CCDCC</color>
下面是我的styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/GreenishBlue</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
AndroidManifest
修改为:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomTheme">
文件 res/values/styles.xml
如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColor">#000</item> //black color for text
<item name="android:textColorHint">#939393</item> //Gray color for hint
</style>
</resources>
将以下代码添加到您现有的 AppTheme
将更改控件中的默认文本颜色,其中文本颜色未在 xml 中内联设置,使用不同的样式或动态。
<item name="android:textColor">#000000</item>
<item name="android:textColorHint">#666666</item>