FloatingActionButton showing two colors (circles)
up vote
0
down vote
favorite
I added a FloatingActionButton in the layout where its only parent is a CoordinatorLayout, so I don't understand where the backgroundTint color is coming from.
I tried to change the color to match the inner circle, but it changes the whole button to a solid color.
I also applied a different style, but it does not change the button at all.
I fixed this problem in the past, but I don't remember how I did it.
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end" />

add a comment |
up vote
0
down vote
favorite
I added a FloatingActionButton in the layout where its only parent is a CoordinatorLayout, so I don't understand where the backgroundTint color is coming from.
I tried to change the color to match the inner circle, but it changes the whole button to a solid color.
I also applied a different style, but it does not change the button at all.
I fixed this problem in the past, but I don't remember how I did it.
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end" />

What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
– aminography
Nov 11 at 6:15
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I added a FloatingActionButton in the layout where its only parent is a CoordinatorLayout, so I don't understand where the backgroundTint color is coming from.
I tried to change the color to match the inner circle, but it changes the whole button to a solid color.
I also applied a different style, but it does not change the button at all.
I fixed this problem in the past, but I don't remember how I did it.
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end" />

I added a FloatingActionButton in the layout where its only parent is a CoordinatorLayout, so I don't understand where the backgroundTint color is coming from.
I tried to change the color to match the inner circle, but it changes the whole button to a solid color.
I also applied a different style, but it does not change the button at all.
I fixed this problem in the past, but I don't remember how I did it.
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end" />

asked Nov 11 at 3:10
Pitos
467
467
What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
– aminography
Nov 11 at 6:15
add a comment |
What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
– aminography
Nov 11 at 6:15
What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
– aminography
Nov 11 at 6:15
What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
– aminography
Nov 11 at 6:15
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
The gray color comes from your colorAccent defined for the app theme in style.xml. Now the @drawable/ic_action_add is a plus sign inside a filled circle. Try to use below icon instead:
ic_add_black_24dp.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>

Then set a crimson color to the FloatingActionButton's background tint and the gray one for icon tint:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:tint="#404D54"
app:backgroundTint="#6F303A"
app:srcCompat="@drawable/ic_add_black_24dp" />
Result:

add a comment |
up vote
0
down vote
You are not providing any app:backgroundTint, so it is using the default colorAccent from colors.xml.
To solve this:
1.Add a new color to colors.xml
<color name="fab_tint">#33d1ac</color>
2.Change the code as follows:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/fab_tint"/>
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%2f53245523%2ffloatingactionbutton-showing-two-colors-circles%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
up vote
1
down vote
accepted
The gray color comes from your colorAccent defined for the app theme in style.xml. Now the @drawable/ic_action_add is a plus sign inside a filled circle. Try to use below icon instead:
ic_add_black_24dp.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>

Then set a crimson color to the FloatingActionButton's background tint and the gray one for icon tint:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:tint="#404D54"
app:backgroundTint="#6F303A"
app:srcCompat="@drawable/ic_add_black_24dp" />
Result:

add a comment |
up vote
1
down vote
accepted
The gray color comes from your colorAccent defined for the app theme in style.xml. Now the @drawable/ic_action_add is a plus sign inside a filled circle. Try to use below icon instead:
ic_add_black_24dp.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>

Then set a crimson color to the FloatingActionButton's background tint and the gray one for icon tint:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:tint="#404D54"
app:backgroundTint="#6F303A"
app:srcCompat="@drawable/ic_add_black_24dp" />
Result:

add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The gray color comes from your colorAccent defined for the app theme in style.xml. Now the @drawable/ic_action_add is a plus sign inside a filled circle. Try to use below icon instead:
ic_add_black_24dp.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>

Then set a crimson color to the FloatingActionButton's background tint and the gray one for icon tint:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:tint="#404D54"
app:backgroundTint="#6F303A"
app:srcCompat="@drawable/ic_add_black_24dp" />
Result:

The gray color comes from your colorAccent defined for the app theme in style.xml. Now the @drawable/ic_action_add is a plus sign inside a filled circle. Try to use below icon instead:
ic_add_black_24dp.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>

Then set a crimson color to the FloatingActionButton's background tint and the gray one for icon tint:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:tint="#404D54"
app:backgroundTint="#6F303A"
app:srcCompat="@drawable/ic_add_black_24dp" />
Result:

edited Nov 11 at 10:07
answered Nov 11 at 5:15
aminography
4,96021129
4,96021129
add a comment |
add a comment |
up vote
0
down vote
You are not providing any app:backgroundTint, so it is using the default colorAccent from colors.xml.
To solve this:
1.Add a new color to colors.xml
<color name="fab_tint">#33d1ac</color>
2.Change the code as follows:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/fab_tint"/>
add a comment |
up vote
0
down vote
You are not providing any app:backgroundTint, so it is using the default colorAccent from colors.xml.
To solve this:
1.Add a new color to colors.xml
<color name="fab_tint">#33d1ac</color>
2.Change the code as follows:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/fab_tint"/>
add a comment |
up vote
0
down vote
up vote
0
down vote
You are not providing any app:backgroundTint, so it is using the default colorAccent from colors.xml.
To solve this:
1.Add a new color to colors.xml
<color name="fab_tint">#33d1ac</color>
2.Change the code as follows:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/fab_tint"/>
You are not providing any app:backgroundTint, so it is using the default colorAccent from colors.xml.
To solve this:
1.Add a new color to colors.xml
<color name="fab_tint">#33d1ac</color>
2.Change the code as follows:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@+id/edit_layout"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/fab_tint"/>
answered Nov 11 at 5:40
Touhidul Islam
872314
872314
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53245523%2ffloatingactionbutton-showing-two-colors-circles%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
What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
– aminography
Nov 11 at 6:15