esskar
esskar

Reputation: 10940

CoordinatorLayout.Behavior: how to set it programmatically

I implemented a CoordinatorLayout.Behavior for my custom view. When I decorate my view with app:layout_behavior and pass it my behavior, it works good.

Now I want to add my view dynamically to the CoordinatorLayout and apply the behavior as well, but I did not find a way to apply it.

EDIT: I found this website on how to use a a third-party fab with the coordinator layout. The implementation shows the usage of @CoordinatorLayout.DefaultBehavior. When I try to use it in my Xamarin code, `CoordinatorLayout.DefaultBehaviour' is an interface. How can I adapt that code?

Upvotes: 2

Views: 2757

Answers (1)

Bryan Herbst
Bryan Herbst

Reputation: 67199

CoordinatorLayout, like most ViewGroups, has its own LayoutParams class. This class contains all of the data that you can pass in with layout_ attributes in XML.

Specifically, you are looking for CoordinateLayout.LayoutParams#setBehavior().

Upvotes: 2

Related Questions