Material Button Icon is showing without color
I am using the following material button:
<android.support.design.button.MaterialButton
android:id="@+id/bFavourite" style="@style/Widget.MaterialComponents.Button.UnelevatedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:insetTop="0dp"
android:insetBottom="0dp"
android:textAllCaps="false"
android:textSize="20sp"
app:backgroundTint="@color/main_dark_blue"
app:backgroundTintMode="src_over"
app:cornerRadius="0dp"
app:icon="@drawable/heart_filled"
app:iconGravity="textStart"
app:iconPadding="0dp" />
heart_filled
is a png of a red heart. However the icon is showing without any color (i.e., a white heart).
Why is the actual color of the image not showing?
Thank you
android
add a comment |
I am using the following material button:
<android.support.design.button.MaterialButton
android:id="@+id/bFavourite" style="@style/Widget.MaterialComponents.Button.UnelevatedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:insetTop="0dp"
android:insetBottom="0dp"
android:textAllCaps="false"
android:textSize="20sp"
app:backgroundTint="@color/main_dark_blue"
app:backgroundTintMode="src_over"
app:cornerRadius="0dp"
app:icon="@drawable/heart_filled"
app:iconGravity="textStart"
app:iconPadding="0dp" />
heart_filled
is a png of a red heart. However the icon is showing without any color (i.e., a white heart).
Why is the actual color of the image not showing?
Thank you
android
add a comment |
I am using the following material button:
<android.support.design.button.MaterialButton
android:id="@+id/bFavourite" style="@style/Widget.MaterialComponents.Button.UnelevatedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:insetTop="0dp"
android:insetBottom="0dp"
android:textAllCaps="false"
android:textSize="20sp"
app:backgroundTint="@color/main_dark_blue"
app:backgroundTintMode="src_over"
app:cornerRadius="0dp"
app:icon="@drawable/heart_filled"
app:iconGravity="textStart"
app:iconPadding="0dp" />
heart_filled
is a png of a red heart. However the icon is showing without any color (i.e., a white heart).
Why is the actual color of the image not showing?
Thank you
android
I am using the following material button:
<android.support.design.button.MaterialButton
android:id="@+id/bFavourite" style="@style/Widget.MaterialComponents.Button.UnelevatedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:insetTop="0dp"
android:insetBottom="0dp"
android:textAllCaps="false"
android:textSize="20sp"
app:backgroundTint="@color/main_dark_blue"
app:backgroundTintMode="src_over"
app:cornerRadius="0dp"
app:icon="@drawable/heart_filled"
app:iconGravity="textStart"
app:iconPadding="0dp" />
heart_filled
is a png of a red heart. However the icon is showing without any color (i.e., a white heart).
Why is the actual color of the image not showing?
Thank you
android
android
edited Nov 25 '18 at 1:15
TeeKea
3,22851732
3,22851732
asked Nov 24 '18 at 19:06
SnakeSnake
5,7941074173
5,7941074173
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can try to set the iconTint
attribute of the Button:
app:iconTint="#ffffff"
I dont want to set the colors from xml. I want my png image to simply show . I have other buttons with way more complicated coloring and they are showing all as white
– Snake
Nov 24 '18 at 21:52
Yes I know how it is when you expect something to behave like it should, just like a white icon to be white, but in AS I've seen a lot of weird behavior (like icons not even showing) and in these cases if there is a workaround I take it. So if this works I suggest you do it. If not then there is trouble.
– forpas
Nov 24 '18 at 21:56
add a comment |
You can use app:iconTint="@android:color/white"
because they mention this in docs MaterialButton Docs
I dont want to set the color code. I want the png image to show as is
– Snake
Nov 24 '18 at 21:52
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461491%2fmaterial-button-icon-is-showing-without-color%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try to set the iconTint
attribute of the Button:
app:iconTint="#ffffff"
I dont want to set the colors from xml. I want my png image to simply show . I have other buttons with way more complicated coloring and they are showing all as white
– Snake
Nov 24 '18 at 21:52
Yes I know how it is when you expect something to behave like it should, just like a white icon to be white, but in AS I've seen a lot of weird behavior (like icons not even showing) and in these cases if there is a workaround I take it. So if this works I suggest you do it. If not then there is trouble.
– forpas
Nov 24 '18 at 21:56
add a comment |
You can try to set the iconTint
attribute of the Button:
app:iconTint="#ffffff"
I dont want to set the colors from xml. I want my png image to simply show . I have other buttons with way more complicated coloring and they are showing all as white
– Snake
Nov 24 '18 at 21:52
Yes I know how it is when you expect something to behave like it should, just like a white icon to be white, but in AS I've seen a lot of weird behavior (like icons not even showing) and in these cases if there is a workaround I take it. So if this works I suggest you do it. If not then there is trouble.
– forpas
Nov 24 '18 at 21:56
add a comment |
You can try to set the iconTint
attribute of the Button:
app:iconTint="#ffffff"
You can try to set the iconTint
attribute of the Button:
app:iconTint="#ffffff"
answered Nov 24 '18 at 19:16
forpasforpas
15.2k3626
15.2k3626
I dont want to set the colors from xml. I want my png image to simply show . I have other buttons with way more complicated coloring and they are showing all as white
– Snake
Nov 24 '18 at 21:52
Yes I know how it is when you expect something to behave like it should, just like a white icon to be white, but in AS I've seen a lot of weird behavior (like icons not even showing) and in these cases if there is a workaround I take it. So if this works I suggest you do it. If not then there is trouble.
– forpas
Nov 24 '18 at 21:56
add a comment |
I dont want to set the colors from xml. I want my png image to simply show . I have other buttons with way more complicated coloring and they are showing all as white
– Snake
Nov 24 '18 at 21:52
Yes I know how it is when you expect something to behave like it should, just like a white icon to be white, but in AS I've seen a lot of weird behavior (like icons not even showing) and in these cases if there is a workaround I take it. So if this works I suggest you do it. If not then there is trouble.
– forpas
Nov 24 '18 at 21:56
I dont want to set the colors from xml. I want my png image to simply show . I have other buttons with way more complicated coloring and they are showing all as white
– Snake
Nov 24 '18 at 21:52
I dont want to set the colors from xml. I want my png image to simply show . I have other buttons with way more complicated coloring and they are showing all as white
– Snake
Nov 24 '18 at 21:52
Yes I know how it is when you expect something to behave like it should, just like a white icon to be white, but in AS I've seen a lot of weird behavior (like icons not even showing) and in these cases if there is a workaround I take it. So if this works I suggest you do it. If not then there is trouble.
– forpas
Nov 24 '18 at 21:56
Yes I know how it is when you expect something to behave like it should, just like a white icon to be white, but in AS I've seen a lot of weird behavior (like icons not even showing) and in these cases if there is a workaround I take it. So if this works I suggest you do it. If not then there is trouble.
– forpas
Nov 24 '18 at 21:56
add a comment |
You can use app:iconTint="@android:color/white"
because they mention this in docs MaterialButton Docs
I dont want to set the color code. I want the png image to show as is
– Snake
Nov 24 '18 at 21:52
add a comment |
You can use app:iconTint="@android:color/white"
because they mention this in docs MaterialButton Docs
I dont want to set the color code. I want the png image to show as is
– Snake
Nov 24 '18 at 21:52
add a comment |
You can use app:iconTint="@android:color/white"
because they mention this in docs MaterialButton Docs
You can use app:iconTint="@android:color/white"
because they mention this in docs MaterialButton Docs
answered Nov 24 '18 at 19:33
Amjad AlwarehAmjad Alwareh
514
514
I dont want to set the color code. I want the png image to show as is
– Snake
Nov 24 '18 at 21:52
add a comment |
I dont want to set the color code. I want the png image to show as is
– Snake
Nov 24 '18 at 21:52
I dont want to set the color code. I want the png image to show as is
– Snake
Nov 24 '18 at 21:52
I dont want to set the color code. I want the png image to show as is
– Snake
Nov 24 '18 at 21:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461491%2fmaterial-button-icon-is-showing-without-color%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown