Explanation and solution at the bottom.
I am developing one slider layout animation, the animation work fine but when all processes end, they get next E
You should not make the LayoutParmas
object of the layout whose dimension you want to set from java. Rather you should make the LayoutParams
object of the parent layout. For example in the layout below to set the layout params of the LinearLayout
you have to make the LayoutParmas
of RelativeLayout
not LinearLayout
itself:
In activity class:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(30,30); // parent params
linearLayout.setLayoutParmas(params); // child layout
If you want to set the params of the RelativeLayout
, it seems it doesn't have any parent but it has a parent created by android framework which is a frame layout:
FrameLayout.LayoutParmas params = new FrameLayout.LayoutParmas(30, 30); // FrameLayout is a parent-created by android framework
relativeLayout.setLayoutParmas(params); // relative layout is child here