How to add and remove layout behavior programmatically to LinearLayout

吃可爱长大的小学妹 提交于 2020-01-06 16:01:22

问题


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?


回答1:


You're misunderstanding LayoutParams concept a bit.

LayoutParams object is related to the enclosing ViewGroup, not to the modified ViewGroup itself.



来源:https://stackoverflow.com/questions/38530196/how-to-add-and-remove-layout-behavior-programmatically-to-linearlayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!