I have a linear layout that is contained inside a relative layout. It is set in the XML file to be to the right of another linear layout (this works fine). In some cases I
add the following code to your existing code
linearLayoutToMove.setLayoutParams(layoutParams)
I think this should do the job. In case if the above line dont work, try to call linearLayoutToMove.invalidate() after the above line.
linearLayoutToMove.invalidate()