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
I ran into a similar problem and I found the answer here. Basically, you should choose the LayoutParams depending on the parent, in your case new LinearLayout.LayoutParams should be new RelativeLayout.LayoutParams.
new LinearLayout.LayoutParams
new RelativeLayout.LayoutParams