This repo demonstrates the problem and solution to this question on Stack Overflow. https://stackoverflow.com/questions/55801511/how-to-set-width-margin-of-view-programmatically-relative-another-view-within-co
The solution is tagged. Everything before that demonstrated the problem.