11

How to change the default color of send icon on this ImageButton?

<ImageButton
    android:id="@+id/ImageButton1"
    android:layout_width="0dp"
    android:paddingTop="5dip"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:background="@null"
    android:gravity="right"
    android:scaleType="center"
    android:src="@android:drawable/ic_menu_send" />

enter image description here

I want to use gray instead of current white color.

Community
  • 1
  • 1
Farzan Najipour
  • 2,244
  • 4
  • 30
  • 71

6 Answers6

39

Add tint attribute and you can set any color you want. Also you can set android:tintMode attribute (Which says how the color should apply).

 <ImageButton
        android:id="@+id/ImageButton1"
        android:layout_width="64dp"
        android:layout_height="64dp"
        android:adjustViewBounds="true"
        android:background="@null"
        android:gravity="right"
        android:paddingTop="5dip"
        android:scaleType="center"
        android:tint="@color/colorAccent"
        android:src="@android:drawable/ic_menu_send" />
Tharindu Welagedara
  • 2,520
  • 14
  • 24
5

You can use colorFilter on image view and can give any color runtime.

iv.setColorFilter(getResources().getColor(R.color.color_gray),
                PorterDuff.Mode.SRC_ATOP);
Wasim K. Memon
  • 5,516
  • 4
  • 35
  • 50
4

Add android:tint attribute to set the icon colour.

<ImageButton
    android:id="@+id/ImageButton1"
    android:layout_width="0dp"
    android:paddingTop="5dip"
    android:layout_weight="1"
    android:tint="@color/background_red"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:background="@null"
    android:gravity="right"
    android:scaleType="center"
    android:src="@android:drawable/ic_menu_send" />
Reaz Murshed
  • 21,071
  • 12
  • 69
  • 87
  • I have tried implementing this for a delete icon, but the red color is faded, am I missing something? – Kevin Apr 14 '18 at 16:05
2

enter image description here

put this image in your drawable folder and then

save it in drawable as an image

<ImageButton
        android:id="@+id/ImageButton1"
        android:layout_width="0dp"
        android:paddingTop="5dip"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:background="@null"
        android:gravity="right"
        android:scaleType="center"
        android:src="@android:drawable/img" />
Boken
  • 3,207
  • 9
  • 25
  • 31
krishna
  • 301
  • 1
  • 8
1

download icon put inside drawable folder

Download Icon

<ImageButton
        android:id="@+id/ImageButton1"
        android:layout_width="0dp"
        android:paddingTop="5dip"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:background="@null"
        android:gravity="right"
        android:scaleType="center"
        android:src="@drawable/downloded_icon_send" />
Boken
  • 3,207
  • 9
  • 25
  • 31
Suhas Bachewar
  • 1,234
  • 7
  • 20
-2

you can put your costomize image in you drawable then you can use it as image src

krishna
  • 301
  • 1
  • 8