I have three buttons in my Actvity inside Linear Layout.
Here i wish all buttons should occupy whole tablelayour equally.
So i have coded as below.
<Linearlayout>
......
<TableLayout
android:id="@+id/tableLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/registerTwitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register Twitter"
android:gravity="left"/>
<Button
android:id="@+id/registerFB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register FaceBook"
android:gravity="center"/>
<Button
android:id="@+id/clearCredentials"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear Credentials"
android:layout_gravity="right" />
</TableRow>
</TableLayout>
</LinearLayout>
But here when i gave code as above i got three buttons occupying whole space.
but alignment are not proper. They are like dancing in air….
where did i made mistake…

Also note above Last button is not visible fully its half hidden…..
I’m really weak in UI design can anyone suggest in that ….
Gravity and layout_gravity are two different fields on your buttons.
Gravity alters the positions of the text in the button and layout_gravity alters the buttons layout position
You have one button using layout_gravity and the other two using gravity.
Make sure you use the right ones!
Edit, here try this code, it is better to use weights: