Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to change icon and color of FloatingActionButton

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 4.92k
    Comment on it

    Here I am writing the way to change the color and icon of FloatingActionButton.

    If I talk about icon of the action button, we need to fulfill of requirement and purpose of Floating button. So we need to change the icon of the FloatingActionButton.

    For color of FloatingActionButton, we do it to look and feel and match the color with our App theme color.

    So To change the icon we need to define it in xml like this

     android:src="@android:drawable/checkbox_on_background"
    

    To change the color,

    app:backgroundTint="@android:color/holo_blue_bright"

    From coding,

    .setBackgroundTintList()
    

    Below is the code

      <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|left"
            android:layout_margin="@dimen/fab_margin"
            app:backgroundTint="@android:color/holo_blue_bright"
            app:elevation="10dp"
    
            android:src="@android:drawable/checkbox_on_background" />
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: