android align View programmatically <p>I have a LinearLayout that comprises some number of TextViews. I set </p> <pre><code>android:gravity="center_horizontal" </code></pre> <p>for the parent Layout and result looks as below (for N=2):</p> <p><img src="https://i.stack.imgur.com/0OeOg.png" alt="enter image description here"></p> <p>I want it look like</p> <p><img src="https://i.stack.imgur.com/4FjE8.png" alt="enter image description here"></p> <p>In other words, I want them to be aligned to the left. More precisely, my plan is to find the longest TextView and then align other TextViews to the left bound of that view. Can anyone explain me in what callback of my Activity can I do it? I tried</p> <pre><code>public void onCreate(Bundle savedInstanceState) </code></pre> <p>but</p> <pre><code>textView.getWidth() </code></pre> <p>(that I use to find the longest TextView) returns 0 for all textViews. The second question is: what method should I use to move a TextView "n" pixels left?</p>