I am having this Button
in my XML:
<Button
android:id="@+id/button_message_me"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@drawable/ic_chat_white_48dp"
android:onClick="clickMessageMe"/>
However, I want to change the color of ic_chat_white_48dp
from white to blue. How to do change?
What I already tried so far:
After reading this post, I tried using android:tint="@color/blue"
but it did not work.
So, thinking that I might need to use ImageButton
instead of Button
(as mentioned in the answer) I replaced Button
with ImageButton
in my XML but I landed up getting exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{chat.knowme.knowme/chat.knowme.knowme.ShowProfileActivity}: java.lang.ClassCastException: android.support.v7.widget.AppCompatImageButton cannot be cast to android.widget.Button
Any help would be really appreciated. Many thanks!
Update:
The crash was because I was casting the ImageButton
to Button
in my source. I fixed it and now doesn't crash anymore (thanks to Patel Pinkal for his answer).
However, color still remain unchanged even with ImageButton