in my latest Android game i had the problem that i had a TableLayout with 4×4 icons (cards) in it. There should be a border between them. But neither setting „android:layout_margin“ or anything else i tried did work 🙁 So i had the idea of surrounding each of my table cells content (the icon) with a LinearLayout that only containt the content (the icon) and set a padding (left, right, top, bottom, 2px) on that LinearLayout. And: it works perfectly 😀 Hope that helps many developers that also have problems with TableLayout and borders / margins.
See the app screenshot for a view of what i wanted to do: