android 扇形悬浮按钮,android 利用FloatActionButton悬浮按钮实现扇形折叠与隐藏

android 利用FloatActionButton悬浮按钮实现扇形折叠与隐藏

首先请看效果图:

6f504dec95e5ddda35ff0c216053aaf1.png

来看看布局代码:

因为,我们用floatactionbutton,点击要弹出菜单,弹出的过程和收缩的过程要进行一些动画操作,再此,我将动画封装为工具类。

package com.example.myfloatactionbutton;

import android.content.Context;

import android.view.View;

import android.view.ViewGroup;

import android.view.animation.Animation;

import android.view.animation.AnticipateInterpolator;

import android.view.animation.OvershootInterpolator;

import android.view.animation.RotateAnimation;

import android.view.animation.TranslateAnimation;

import android.widget.ImageButton;

public class MyAnimations {

private static int xOffset = 15;

private static int yOffset = -13;

public static void initOffset(Context context) {

//获取屏幕的密度 context.getResources().getDisplayMetrics().density 设置移动的距离

xOffset = (int) (10 * context.getResources().getDisplayMetrics().density);

yOffset = -(int) (8 * context.getResources().getDisplayMetrics().density);

}

public static Animation getRotateAnimation(float fromDegrees,

float toDegrees, int durationMillis) {

//旋转,前两个参数设置旋转角度,后四个设置旋转中心

RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值