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
?
Asked
Active
Viewed 2,312 times
1

Akeshwar Jha
- 4,516
- 8
- 52
- 91

Aspiring Dev
- 505
- 1
- 4
- 17
-
http://stackoverflow.com/a/33707476/5038993 – Akeshwar Jha Jul 25 '16 at 12:55
-
@Akeshwar that doesn't work on `LinearLayout` because its `LinearLayout.LayoutParams` can't be cast to `CoordinatorLayout.LayoutParams`. In fact I have a comment under that same answer stating that fact. – Aspiring Dev Jul 26 '16 at 13:18
1 Answers
0
You're misunderstanding LayoutParams
concept a bit.
LayoutParams
object is related to the enclosing ViewGroup
, not to the modified ViewGroup
itself.

Graham
- 7,431
- 18
- 59
- 84

Bartek Lipinski
- 30,698
- 10
- 94
- 132
-
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. – Aspiring Dev Sep 07 '16 at 19:55
-
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`** – Bartek Lipinski Sep 08 '16 at 07:29
-
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. – Aspiring Dev Sep 08 '16 at 12:22