I want all buttons to be same size. But the button in the middle of each row is larger than the two (to fill up space). How can I adjust their sizes. I am sure it can be done without using "dip" or any other manual method. Thanks.
the button in the middle of each row is larger than the two (to fill up space).
I suspect this is because you have the following attribute set in your TableLayout:
If you set width of a button to "wrap_content" the button is sized large enough to hold the contents(the button text). So, depending on what text you set for a button each Button size will vary unless you hardcode a fixed value for the width.
Also, layout_weight will just specify the ratio in which the extra space is to be split across views. So, if the buttons are not of same width splitting the extra space evenly would not make all the buttons of same size.
An option you can consider is having all the button texts of same length(by using padding etc.)
Thanks for your help Monu. I resolved the problem. Here is what I did. Per your recommendation I removed the stretch column attribute. That resolved the problem of size difference. All buttons were same size but there was extra space left on each row. For that I added 'android:layout_weight="1"' and that made all buttons equal size and fill up the remaining space on screen. Here is my final code in case it might help someone in future.