Does TableLayout have Borders?
I am working on a droid application, and I am using a TableLayout but cannot get it to look how I want. I want to have 2 columns, one for the text and one for the monetary value, but I cannot get them centered (in the table) and showing up next to each other.
I am trying to get it to look like this...
http://s2.postimage.org/8wpons46m/whmcs.png
but since I cannot actually see the borders, I cannot figure out how to fix it. This is what it currently looks like...
Here is the XML layout for my Table
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0"
android:background="@drawable/round_table">
<TableRow>
<TextView
android:layout_column="1"
android:text="Today's Income:"
开发者_开发问答 android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="center"
android:layout_width="0dip"
android:padding="3dip" />
<TextView
android:text="$0.00 USD"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="center"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#000000" />
<TableRow>
<TextView
android:layout_column="1"
android:text="Monthly Income:"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="center"
android:padding="3dip" />
<TextView
android:text="$0.00 USD"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="center"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#000000" />
<TableRow>
<TextView
android:layout_column="1"
android:text="Annual Income:"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="center"
android:padding="3dip" />
<TextView
android:text="$0.00 USD"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="center"
android:padding="3dip" />
</TableRow>
</TableLayout>
use layout_weight, something on the lines of below code should work for your purpose.
<TableRow>
<TextView
android:text="Today's Income:"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="right"
android:layout_weight="0.6"
android:padding="3dip" />
<TextView
android:text="$0.00 USD"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:layout_weight="0.4"
android:gravity="left"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#000000" />
<TableRow>
<TextView
android:text="Monthly Income:"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="right"
android:layout_weight="0.6"
android:padding="3dip" />
<TextView
android:text="$0.00 USD"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="left"
android:layout_weight="0.4"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#000000" />
<TableRow>
<TextView
android:text="Annual Income:"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="right"
android:layout_weight="0.6"
android:padding="3dip" />
<TextView
android:text="$0.00 USD"
android:typeface="sans"
android:textSize="10sp"
android:textColor="#000000"
android:gravity="left"
android:layout_weight="0.4"
android:padding="3dip" />
</TableRow>
精彩评论