Search code examples
androidandroid-studiobuttonmaterial-designfloating-action-button

How to make a radial floating action button like this in android?


I am currently new to android designing and material design. It would be great if anyone could help me out on how to make a radial floating action android button like this

https://codepen.io/mblode/pen/pvVpaE

HTML

<div class="container"><div class="row"><div class="col-sm-12">
  <h1 class="text-center">Radial Floating Action Button</h1>
  <p class="text-center">(click)</p>
</div></div></div>

<div class="radial">
  <button class="fa fa-paper-plane fa-3x" id="fa-1"></button>
  <button class="fa fa-home fa-3x" id="fa-2"></button>
  <button class="fa fa-search fa-3x" id="fa-3"></button>
  <button class="fab">
    <div class="fa fa-plus fa-3x" id="plus"></div>
  </button>
</div> 

CSS

@import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Lato:300,400,700);

$font-stack: 'Lato', sans-serif;

* { box-sizing: border-box; }

$red: #ff4081;

body {
  font-family: $font-stack;
  background: #efefef;
}

button:focus {
  outline: 0;
}

.radial {
  width: 100px;
  height: 100px;
  position: fixed;
  right: 25px;
  bottom: 25px;
  background: $red;
  border-radius: 50%;
  transition: all 0.5s;
  box-shadow: 0px 2px 4px rgba(0,0,0,0.15), 0px 4px 8px rgba(0,0,0,0.2);
}

.fab {
  border: none;
  color: white;
  background-color: #ff4081;
  border-radius: 50%;
  width: 100px;
  height: 100px;
  position: fixed;
  right: 25px;
  bottom: 25px;
  transition: all 0.5s;
  &:hover {
    background-color: darken($red, 15);
  }
}

#plus {
  transition: all 0.5s;
  margin-top: 7px;
}

#fa-1, #fa-2, #fa-3 {
  position: fixed;
  background: transparent;
  border: none;
  right: 60px;
  bottom: 57px;
  transition: all 0.5s;
  color: white;

  &:hover {
   tansition-delay: 0s;
   color: lighten($red, 15); 
  }
}

.radial {
  &.open {
    height: 400px;
    width: 400px;
    right: -125px;
    bottom: -125px;

    .fab {
      background-color: darken($red, 15);
      box-shadow: 0px 2px 4px rgba(0,0,0,0.15), 0px 4px 8px rgba(0,0,0,0.2);
    }

    #plus {
      transform: rotateZ(135deg) translate(-1px, 3px);
    }
    #fa-1 {
      transition-delay: 0s;
      transform: translate(-110px, 10px);
    }
    #fa-2 {
      transition-delay: 0.1s;
      transform: translate(-85px, -85px);
    }
    #fa-3 {
      transition-delay: 0.2s;
      transform: translate(10px, -110px);
    }
  }
}

JS

$(document).ready(function(){
  $('.fab').click (function(){
    $('.radial').toggleClass('open');
  });
});

If this is not possible to develop, a good radial floating action button would also work!


Solution

  • This animation is not so difficult, you can easily perform this using basic animations in android and playing around with delay. You can also use https://github.com/oguzbilgener/CircularFloatingActionMenu, it also has option for custom animation but i don't think you will be able to achieve the exact same animation using this library