Reputation: 6403
How to align Product Name and Product Grade correctly. I retrieve the product name from db, since the name is too long the align was not in same position. Please help Thanks
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/birdnesttoppanel"
android:gravity="center_horizontal" >
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<LinearLayout
android:layout_span="6"
android:gravity="center" >
<ImageButton
android:id="@+id/preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:background="@drawable/newclick"
android:text="Click here to view the picture" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18dp"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow6new"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<LinearLayout
android:layout_span="6"
android:gravity="center" >
<TextView
android:id="@+id/ProductName1"
android:text="@string/ProductName"
android:textStyle="bold"
android:typeface="serif"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:id="@+id/ProductName2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:id="@+id/ProductName3"
android:text=""
android:textStyle="bold"
android:typeface="serif"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</TableRow>
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="6"
android:gravity="center"
android:textSize="2dp"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow6new1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<LinearLayout
android:layout_span="6"
android:gravity="center" >
<TextView
android:id="@+id/ProductGrade1"
android:text="@string/ProductGrade"
android:textStyle="bold"
android:typeface="serif"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TextView>
<TextView
android:id="@+id/ProductGrade2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TextView>
<TextView
android:id="@+id/ProductGrade3"
android:text=""
android:textStyle="bold"
android:typeface="serif"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TextView>
</LinearLayout>
</TableRow>
Upvotes: 2
Views: 7324
Reputation: 16043
Its somehow hard to distinguish which labels correspond in XML file, but let me guess:
So, for the TableRows:
`android:id="@+id/tableRow6new"` and `android:id="@+id/tableRow6new1"`
change the grativity to left: android:gravity="left"
Also, I see both TableRows have a LinearLayout:
<LinearLayout
android:layout_span="6"
android:gravity="center" >
Change their gravity to left too: android:gravity="left"
Hope it will solve the issue.
Upvotes: 3