microsoft / fluentui-system-icons

Fluent System Icons are a collection of familiar, friendly and modern icons from Microsoft.
https://aka.ms/fluentui-system-icons
MIT License
5.85k stars 513 forks source link

[Android] Icon color #424

Open tipa opened 2 years ago

tipa commented 2 years ago

In the Android drawables, their fill color is defined as `android:fillColor="@color/fluent_default_icon_tint".

The docs say (here) that a default color is used (#212121) which can be overridden. However, there is no default defined, because I am just importing the drawable xmls. So I need to define the color fluent_default_icon_tint myself.

My goal is to have the icon color match my apps text color (?android:attr/textColorPrimary), and because I am using multiple themes in my app which can have different text colors, my first guess was to define fluent_default_icon_tint like this in my colors.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <color name="fluent_default_icon_tint">?android:attr/textColorPrimary</color>
</resources>

While this does work on higher Android versions, this does not work on Android 6 or Android 9 (and maybe other versions). The problem is documented here

Checking your docs again, it is suggested to use a fluent_default_icon_tint.xml file to override (or actually, define) the color:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:color="?android:attr/textColorPrimary"/>
</selector>

This actually worked on a physical Android 6 device, but still not on my Android 6 + 9 emulators as well as a API level 9 physical Chromebook. The icons are all in magenta (#FF00FF) color....

So my suggestion would be to use a similar system like the Material icons from Google: https://fonts.google.com/icons

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:tint="?attr/colorControlNormal">
  <path
      android:fillColor="@android:color/white"
      android:pathData="...."/>
</vector>

android:tint="?attr/colorControlNormal" could be replaced with android:tint="?attr/fluent_default_icon_tint".

RokeJulianLockhart commented 2 years ago

Although this suggestion may be useful anyway, I do not believe that we should implement any modification based upon the rationale that such low API levels are not supported by what currently exists, because "http://gs.statcounter.com/os-version-market-share/android" demonstrates that Android 6 is not currently utilized significantly much.