title: Android: How to change the gravity of an ImageButton placed into a dynamically created layouts
body: <p>I have a main dynamically generated <code>LinearLayout</code> containing 4 items :
  - A <code>TextView</code> (dynamic <code>width</code>)
  - An <code>ImageView</code> (static <code>width</code>)
  - A <code>TextView</code> (dynamic <code>width</code>)
  - An <code>ImageButton</code> (static <code>width</code>)</p>
  
  <p>The 3 first items should be stuck together and the last one should float on the right of the screen.</p>
  
  <pre><code>Name - Rating starts - Number of reviews................. Gmap icon 
  </code></pre>
  
  <p>Current :
  <a href="https://i.stack.imgur.com/uXPmS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uXPmS.png" alt="Current screen"></a></p>
  
  <p>Expected :
  <a href="https://i.stack.imgur.com/1M8Ov.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1M8Ov.png" alt="Expected screen"></a></p>
  
  <p>I have found a solution calculating the width of the generated items and then using that value to set the width of a <code>layout</code> containing the items 2 and 3 together.</p>