Android 当FAB重力处于底部时,圆形分隔缝不工作
我正在将浮动操作按钮(FAB)变形为工具栏,使用以下代码,一切都能顺利完美地工作: 布局文件:Android 当FAB重力处于底部时,圆形分隔缝不工作,android,animation,floating-action-button,circularreveal,Android,Animation,Floating Action Button,Circularreveal,我正在将浮动操作按钮(FAB)变形为工具栏,使用以下代码,一切都能顺利完美地工作: 布局文件: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="sg.com.saurabh.designlibraryexpirements.ToolbarMorphActivity">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_vertical_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:src="@drawable/ic_add" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="@style/ToolBarTheme"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:visibility="invisible"
tools:visibility="visible" />
</FrameLayout>
圆形分隔缝按照上述布局的预期工作。然而,当我将工厂和工具栏的布局更改为底部而不是顶部时,事情就破裂了。“旋转”动画工作,然后工具栏仅显示,而不显示圆形分隔缝动画。我完全被它如何打破圆形展示动画所难倒。
您的解决方案是替换:
private void revealToolbar() {
....
int x = (int)fab.getX() + fab.getWidth()/2;
int y = (int)fab.getY() + fab.getHeight()/2;
....
}
借
原因是createCircularReveal
将参数centerY
和centerX
作为动画圆中心相对于视图的坐标(即在本例中为工具栏
)
见:
啊。现在工作。谢谢
private void revealToolbar() {
....
int x = (int)fab.getX() + fab.getWidth()/2;
int y = (int)fab.getY() + fab.getHeight()/2;
....
}
private void revealToolbar() {
...
int x = (int)fab.getX() + fab.getWidth()/2;
int y = fab.getHeight()/2;
...
}
........
* @param view The View will be clipped to the animating circle.
* @param centerX The x coordinate of the center of the animating circle, relative to
* <code>view</code>.
* @param centerY The y coordinate of the center of the animating circle, relative to
* <code>view</code>.
* @param startRadius The starting radius of the animating circle.
* @param endRadius The ending radius of the animating circle.
*/