Dynamically changing the linearlayout width or height on Android

前端 未结 4 1370
离开以前
离开以前 2020-12-08 10:28

I am trying to change linear layout or any other widget width or height dynamically but throwing exception.

My layout is:



        
4条回答
  •  爱一瞬间的悲伤
    2020-12-08 10:52

    The problem here is that when you set the layout params the type needs to be that of the parent, in this case that is a FrameLayout. You need to do this:

    ll.setLayoutParams(new FrameLayout.LayoutParams(30,60));
    

提交回复
热议问题