Reputation: 2879
I'm building an Android app, and using a TableLayout ViewGroup to display my data.
I would like the TableView to occupy the entire width of the screen, however I'm having trouble getting this to work.
What seems to happen, is the table is only as wide as the widest element in the table, in this case, the image that I put in it.
Here's a screenshot to illustrate the problem.
Additionally, here's the XML source code of my layout.
What specifically should I do to have the layout stretch to the entire width of the screen?
Thanks in advance!
Upvotes: 0
Views: 80
Reputation: 12090
You only have 1 column. Therefore, it should be stretchColumns="0"
.
Upvotes: 1
Reputation: 1007286
Creating a single-column TableLayout
is pointless and wasteful. Use a vertical LinearLayout
, please. You will probably find that it works better with respect to your problem as a side benefit.
Also, do not repeat the xmlns:android="http://schemas.android.com/apk/res/android"
-- it only needs to go on the root element.
BTW, columns are indexed starting from 0, so you are stretching a non-existent column in your existing TableLayout
.
Upvotes: 1