I think you can change the way you create an image grid as a whole using a GridView , not a TableLayout. With GridView you can control how large your columns are (by calling gridView.setColumnWidth(int) ), and it will really clear your layout / make your code more convenient to manage in the long run. That way, when your user clicks the zoom in button, just increase the column width, create ImageViews in each match_parent grid match_parent , and Android should automatically scale the images for you. I think this will also make it easier to manage click events / future changes in your style and make your xml layout more manageable (fewer lines of code, more portability, fewer errors). For a guide to GridViews, just check out the Google Guide:
http://developer.android.com/guide/topics/ui/layout/gridview.html
For something larger than a column / row or two views of the same type, you really shouldn't use TableLayout anyway.
But if, despite the above, you are really super attached to TableLayout, you have several options. The easiest way is probably related to introducing it to ScrollView and using various methods to scale TableLayout. For example, you can manually adjust the width and height of the TableLayout or set the ScaleGestureDetector on it. This way you can scale content as well as scroll it when it is larger. However, I think GridView is definitely the best option, for many reasons.
source share