You can add the app:layout_behavior="@string/appbar_scrolling_view_behavior"
behavior to a LinearLayout
in the XML declaration but I haven't found a way to do the same in code. With a CoordinatorLayout
you can call CoordinatorLayout.LayoutParams.setBehavior()
but this method isn't available on LinearLayout.LayoutParams
. Is there a way to do something similar for LinearLayout
?
How to add and remove layout behavior programmatically to LinearLayout
Asked Answered
You're misunderstanding LayoutParams
concept a bit.
LayoutParams
object is related to the enclosing ViewGroup
, not to the modified ViewGroup
itself.
That's probably true but on CoordinatorLayout it can be done so I'm wondering if there is a way to do it on LinearLayout too. –
Grime
What exactly "can be done" on
CoordinatorLayout
? Take a good look a the question you posted your original comment. I do not do anything on the CoordinatorLayout
itself. I do something on it's child View
–
Vulcanize Not in CoordinatorLayout itself but when you have a view inside of it. What I meant was that when you had a view inside one you could add and remove LayoutParams programmatically. Not that you did that on CoordinatorLayout directly. –
Grime
© 2022 - 2024 — McMap. All rights reserved.
LinearLayout
because itsLinearLayout.LayoutParams
can't be cast toCoordinatorLayout.LayoutParams
. In fact I have a comment under that same answer stating that fact. – Grime