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" />


enter image description here










share|improve this question






















  • What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
    – aminography
    Nov 11 at 6:15

















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" />


enter image description here










share|improve this question






















  • What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
    – aminography
    Nov 11 at 6:15















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" />


enter image description here










share|improve this question













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" />


enter image description here







android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 3:10









pitos

417




417












  • 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






What is your desired color for FAB and inside icon? Gray FAB with crimson icon or reverse?
– aminography
Nov 11 at 6:15














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>


enter image description here



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:



enter image description here






share|improve this answer






























    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"/>





    share|improve this answer





















      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',
      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
      });


      }
      });














       

      draft saved


      draft discarded


















      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>


      enter image description here



      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:



      enter image description here






      share|improve this answer



























        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>


        enter image description here



        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:



        enter image description here






        share|improve this answer

























          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>


          enter image description here



          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:



          enter image description here






          share|improve this answer














          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>


          enter image description here



          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:



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 11 at 10:07

























          answered Nov 11 at 5:15









          aminography

          3,33311129




          3,33311129
























              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"/>





              share|improve this answer

























                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"/>





                share|improve this answer























                  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"/>





                  share|improve this answer












                  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"/>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 11 at 5:40









                  Touhidul Islam

                  331110




                  331110






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Bressuire

                      Vorschmack

                      Quarantine