【问题标题】:Primary text color for differents attributes不同属性的主要文本颜色
【发布时间】:2015-04-13 14:28:35
【问题描述】:

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

<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>

问题是颜色在任何地方都被修改了,也被修改到我的列表视图中,但我希望我的列表视图的文本是不同的颜色有没有办法做到这一点?

【问题讨论】:

    标签: android xml styles


    【解决方案1】:

    如果你用android.R.layout.simple_list_item_1给listview充气,可以用一个textview做一个简单的布局然后给它充气,用android:textColor="@color/someColor"改变颜色

    【讨论】:

      【解决方案2】:

      在您的 android 资源 style.xml 文件中添加此 &lt;item name="textColorPrimary"&gt;#10a2fc&lt;/item&gt; 以更改您的主要文本颜色。更改十六进制值#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>
      

      如果您的问题解决了,请告诉我。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-01-23
        • 1970-01-01
        • 2022-01-03
        • 1970-01-01
        • 2020-04-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多