不同属性的主要文本颜色

时间:2015-04-13 14:28:35

标签: android xml styles

我的主要文字颜色定义如下:

<color name="primaryTextColor">#ff82ff26</color>

以及我的style.xml:

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/primaryColor</item>

        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/primaryColorDark</item>

        <!-- colorAccent is used as the default value for colorControlActivated
             which is used to tint widgets -->
        <item name="colorAccent">@color/AccentColor</item>

        <item name="android:textColorPrimary">@color/primaryTextColor</item>
        <!-- You can also set colorControlNormal, colorControlActivated
             colorControlHighlight & colorSwitchThumbNormal. -->

    </style>


</resources>

问题是颜色是到处修改的,也是我的listview但是我希望我的listview文本是一个不同的颜色有没有办法做到这一点?

2 个答案:

答案 0 :(得分:0)

如果您使用android.R.layout.simple_list_item_1来扩充列表视图,可以使用一个文本视图进行简单布局,然后对其进行充气,并使用android:textColor="@color/someColor"更改颜色

答案 1 :(得分:0)

在您的android资源style.xml文件中添加此<item name="textColorPrimary">#10a2fc</item>来更改您的主要文字颜色。更改十六进制值#10a2fc或根据需要使用颜色选择器更改颜色。

<resources>

    <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        //change this hex code or use color picker for change your primary text color 
        <item name="textColorPrimary">#10a2fc</item>


    </style>

</resources>

让我知道您的问题是否解决。