【问题标题】:How to make a radial floating action button like this in android?如何在android中制作这样的径向浮动动作按钮?
【发布时间】:2018-11-09 20:39:31
【问题描述】:

我目前是 android 设计和材料设计的新手。如果有人可以帮助我了解如何制作像这样的径向浮动动作 android 按钮,那就太好了

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

如果这无法开发,一个好的径向浮动操作按钮也可以工作!

【问题讨论】:

    标签: android android-studio button material-design floating-action-button


    【解决方案1】:

    这个动画并不难,你可以很容易地使用 android 中的基本动画和延迟播放。你也可以使用https://github.com/oguzbilgener/CircularFloatingActionMenu,它也有自定义动画的选项,但我认为你不能使用这个库实现完全相同的动画

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-20
      • 2020-05-27
      • 1970-01-01
      • 1970-01-01
      • 2022-11-27
      • 2015-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多