0
我正在使用Android示例中的FAB按钮(1)。 如果我明白它的正确性,实现FAB的扩展FrameLayout的构造器会将该大纲视图映射到视图,使视图实例化时视图变为椭圆形。显示动画在视图被剪裁为轮廓之前启动
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr);
setClickable(true);
// Set the outline provider for this view. The provider is given the outline which it can
// then modify as needed. In this case we set the outline to be an oval fitting the height
// and width.
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, getWidth(), getHeight());
}
});
// Finally, enable clipping to the outline, using the provider we set above
setClipToOutline(true);
}
我想OT透露按钮wheneever活动启动: 我申请就可以了显示效果的onWindowFocusChanged活动方法,什么情况是,动画开始,仅在其共完成视图的轮廓被剪辑。
final View fabContainer = findViewById(R.id.create_new_workout_fab);
Animation anim = AnimationUtils.loadAnimation(YourWorkouts.this, R.anim.reveal_fab);
fabContainer.setVisibility(View.VISIBLE);
Animator animator = ViewAnimationUtils.createCircularReveal(
fabContainer, // view to reveal
fabContainer.getWidth()/2, // start X coordinate of reveal
fabContainer.getHeight()/2, // start Y coordinate of reveal
0, // start radius. In most cases - 0
Math.max(fabContainer.getWidth(), fabContainer.getHeight()) // end radius
);
// Set a natural ease-in/ease-out interpolator.
animator.setInterpolator(new AccelerateDecelerateInterpolator());
fabContainer.setClipToOutline(true);
// Finally start the animation
animator.start();
所以,当揭示动画运行时,视图不是椭圆形,并且在揭示动画结束后变成椭圆形。 如代码中所示,我也尝试在开始动画之前手动设置剪辑,但它不起作用。
有人可以帮我吗?