title: LinearLayout.getWidth() not reflecting new width from setLayoutParams
body: <blockquote>
    <p><strong>tl/dr</strong></p>
    
    <p><em>I am trying to change some layouts sizes in code, and I can change some of them, but the other ones that needed to update based on the
    changes won't update together. Instead, they retain the previous width
    that the changed ones had.</em></p>
  </blockquote>
  
  <p>So, I am fooling around with Android Studio and trying to change the size of some LinearLayouts Programatically.</p>
  
  <p>This is what I'm doing:</p>
  
  <pre><code>final LinearLayout ll3 = (LinearLayout)findViewById(R.id.box3);
  ViewGroup.LayoutParams p3 = ll3.getLayoutParams();
  int w3 = 5;
  float aux = (float)w3/15;
  p3.width = Math.round(max*aux);
  ll3.setLayoutParams(p3);
  </code></pre>
  
  <p>and then this is what I'm getting:</p>
  
  <pre><code>Log.i("OnLongClick p3_width", Integer.toString(p3.width));
  Log.i("OnLongClick ll3_getWidth", Integer.toString(ll3.getWidth()));
  </code></pre>
  
  <blockquote>
    <p>OnLongClick p3_width﹕ 179</p>
    
    <p>OnLongClick ll3_getWidth﹕ 224</p>
  </blockquote>
  
  <p>The ll3.getWidth() is returning the previous value, which ll3 HAD before setting the new parameters.
  If I repeat the process, then it will display something like:</p>
  
  <blockquote>
    <p>OnLongClick p3_width﹕ 314 //New Value</p>
    
    <p>OnLongClick ll3_getWidth﹕ 179 //Old (previous) Value</p>
  </blockquote>
  
  <p>I need the ll3.getWidth() to be the same as p3.width, because I'm calling it in another function in order to recalculate the other LinearLayouts that my app has. Otherwise, when the app redraws it, the rectangles changed manually will change, but the other ones (which uses the changes to modify itself) will remain the way that the changed ones were previously (sorry about this sentence).</p>
  
  <p>I'm thinking that this happens because the setLayoutParams must be doing its job further in time, and not before I call getWidth(), but I have no clue if that is trully the problem, and how to fix it.</p>
  
  <p>Any help is apreciated.</p>
  
  <p>Thanks in advance!!!</p>
  
  <p><strong>EDIT2:</strong>
  If I send</p>
  
  <pre><code>openOptionsMenu();
  closeOptionsMenu();
  </code></pre>
  
  <p>It fixes the size of the rectangles. However, it presents a delay doing that, so it is reeeally ugly.
  Anyway, I would need to place whatever is in the middle of openOptionsMenu() to fix that (closeOptionsMenu() doesnt change the view, only closes the menu).</p>