Search code examples
androidandroid-linearlayoutandroid-coordinatorlayoutbehavior

CoordinatorLayout.DefaultBehaviour deprecated, no other option


So according to android documentation, defaultBehaviour is deprecated and AttachedBehaviour should be used instead.

However:

attachedbehaviour

does not "exist" in android. I always receive the Annotation type expected error.

My import is: import androidx.coordinatorlayout.widget.CoordinatorLayout;

Am I using the wrong import?


Solution

  • AttachedBehavior is an interface, not an annotation.

    Therefore your CustomLinearLayout must implement AttachedBehavior and override the getBehavior() method to return an instance of your MoveUpwardBehavior class.