扩展FloationActionButton时如何保持默认行为?

时间:2015-12-11 17:23:12

标签: android android-support-library android-support-design

我创建了自己的FloatingActionButton。它从原始类扩展。

我想重现此picture

的相同行为

但是当我扩展它时,我会失去默认的动画行为。有办法保留它吗?

提前致谢。

3 个答案:

答案 0 :(得分:0)

您可以使用@CoordinatorLayout.DefaultBehavior(FloatingActionButton.Behavior.class)注释您的课程。

@CoordinatorLayout.DefaultBehavior注释定义了View使用的默认CoordinatorLayout行为。在这种情况下,指定FloatingActionButton的行为就可以了。

答案 1 :(得分:0)

您可以使用@DefaultBehavior注释来指定行为类:

@DefaultBehavior(FloatingActionButton.Behavior.class)
public class YourFloatingActionButton extends FloatingActionButton {
  //Your code
}

答案 2 :(得分:0)

我发现了问题。

在我的自定义FAB中,我创建了一个方法隐藏。此方法是从layoutParams中删除anchorId。我没有意识到我超越了超级方法。太傻了。

相关问题