Reputation: 3912
What I am trying to achieve is a simple 3 column, 11 row table. Right now all of the data is displayed in 1 column and 33 rows. Here is the output:
Rank
Percentage
Score
1
1234
13453
2
2352435
312413
3
235325
235423
//etc...
I have messed around with many online examples of TableLayouts but all my output stays the same for all the examples. What I have below is just the last one I tried. Any suggestions?
Highscoresmain.xml
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fillViewport="true" >"
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1" >
<TableRow
android:id="@+id/rowHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/rank"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/percentage"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/score"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TableRow
android:id="@+id/row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/r1r"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/r1p"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/r1s"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TableRow
android:id="@+id/row2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/r2r"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/r2p"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/r2s"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
//TableRows 1 through 10 are identical.
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="MAIN MENU"
android:id="@+id/homeBtn" />
</TableLayout>
</ScrollView>
Upvotes: 0
Views: 242
Reputation: 1479
Do it this way for all your rows in the table
<TableRow
android:id="@+id/rowHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/rank"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/percentage"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/score"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
Upvotes: 1