1

I am using an action drawer with a menu. The icons appear in black as in the following screenshot:

enter image description here

I am trying to change the color of these icons, pretty much the same as in the design guidelines:

Check guidelines: https://www.google.com/design/spec-wear/components/action-drawer.html#action-drawer-usage

However, I cannot find where to do that or which style attribute will allow me to do so.

Abdalrahman Shatou
  • 4,550
  • 6
  • 50
  • 79

2 Answers2

1

If you're using a CircledImageView you can set the tint of the icon directly on the view using setImageTint(int tint).

If you're using a traditional ImageView you need to create a Drawable from your icon resource and apply the tint to it, and then set it to the view:

Drawable iconDrawable = mContext.getResources().getDrawable(R.drawable.icon, mContext.getTheme());
iconDrawable.setTint(mContext.getColor(R.color.bg_color, mContext.getTheme()));
iconView.setImageDrawable(iconDrawable);

EDIT: To access icons in a menu you can do something like this when it's created:

for(int i = 0; i < menu.size(); i++) {
    Drawable iconDrawable = menu.getItem(i).getIcon();
    iconDrawable.setTint(mContext.getColor(R.color.bg_color, mContext.getTheme()));
}
TofferJ
  • 4,678
  • 1
  • 37
  • 49
0

They changed the layout for the Action Drawer items without giving an option to change the color/disable it.

v23/action_drawer_item_view.xml

<ImageView
        android:id="@+id/wearable_support_action_drawer_item_icon"
        android:layout_width="@dimen/action_drawer_item_icon_size"
        android:layout_height="@dimen/action_drawer_item_icon_size"
        android:layout_gravity="center_vertical"
        android:background="@drawable/action_item_icon_background"
        **android:tint="?android:attr/colorBackground"**
        android:padding="@dimen/action_drawer_item_icon_padding"
        android:scaleType="fitCenter"
        tools:ignore="ContentDescription" />

Since there's no access to the adapter, it's not possible change the color.

JoniDS
  • 511
  • 4
  • 7