如何将所有文本颜色更改为默认颜色(文本为黑色,提示为灰色)而不是白色

问题描述 投票:0回答:2

目前我的所有文字和提示颜色默认都是白色的,虽然我可以在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>

android kotlin material-design android-textview
2个回答
0
投票

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>

0
投票

将下面的代码添加到现有的AppTheme将更改控件中的默认文本颜色,其中文本颜色未在xml中内嵌,使用不同的样式或动态。

<item name="android:textColor">#000000</item>     
<item name="android:textColorHint">#666666</item>     
© www.soinside.com 2019 - 2024. All rights reserved.