Android 浮动操作按钮扩展
根据浮动动作按钮的新要求,应合理设置Android 浮动操作按钮扩展,android,android-animation,floating-action-button,Android,Android Animation,Floating Action Button,根据浮动动作按钮的新要求,应合理设置 是否有任何示例/示例可以执行这种转换?在我看来,它就像一个打开自定义工具栏的工具。要使用显示动画,您需要向onCreateView回调中的视图添加onLayoutChange侦听器,如下所示: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Infla
是否有任何示例/示例可以执行这种转换?在我看来,它就像一个打开自定义工具栏的工具。要使用显示动画,您需要向onCreateView回调中的视图添加onLayoutChange侦听器,如下所示:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_map_list, container, false);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
v.removeOnLayoutChangeListener(this);
revealView(view);
}
});
}
return view;
}
其中,revealView()方法将是:
private void revealView(View view) {
toolbar = view.findViewById(R.id.mytoolbar);
int cx = (view.getLeft() + view.getRight()) / 2;
int cy = (view.getTop() + view.getBottom()) / 2;
float radius = Math.max(infoContainer.getWidth(), infoContainer.getHeight()) * 2.0f;
if (infoContainer.getVisibility() == View.INVISIBLE) {
infoContainer.setVisibility(View.VISIBLE);
ViewAnimationUtils.createCircularReveal(infoContainer, cx, cy, 0, radius).start();
} else {
Animator reveal = ViewAnimationUtils.createCircularReveal(
infoContainer, cx, cy, radius, 0);
reveal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
toolbar.setVisibility(View.INVISIBLE);
}
});
reveal.start();
}
}
通过这种方式,您应该能够创建动画。这就是使用它的方法。只需在fab onClick()方法中应用此项即可您可以使用显示动画。单击fab可以启动动画以显示所需的工具栏。当然,晶圆厂只有这个功能。试着看看我的答案这看起来不错。我会尽快测试。很好,让我知道;)我现在没有时间来测试它,但是通读你的代码,我需要的似乎就是它。你能在你的答案中添加一些xml吗?我不能理解一些变量。什么是infoContainer?这看起来像另一个答案,谢谢你的参考!