Android tablelayout reducing the gap between two rows - android

As shown in the image i want to reduce the gap between two rows (marked by red color) so that my edit text appears just below the text.
My code
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip" >
<TextView
android:id="#+id/textView1"
android:text="#string/projectName"
android:textSize="16sp"
android:textAppearance="#string/projectName"
android:textColor="#color/text_color"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip">
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="35dp"
android:inputType="text"
android:singleLine="true"
android:background="#drawable/editbox_background_normal"
android:layout_weight="1"
android:padding="5dip"
/>
</TableRow>
</TableLayout>

Get rid of all those paddings
android:padding="2dip"
android:padding="5dip"
You can use padding left and right instead.
Try this
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/textView1"
android:text="#string/projectName"
android:textSize="16sp"
android:textAppearance="#string/projectName"
android:textColor="#color/text_color"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="35dp"
android:inputType="text"
android:singleLine="true"
android:background="#drawable/editbox_background_normal"
android:layout_weight="1"
/>
</TableRow>
</TableLayout>

Buddy try this,it must help you
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/textView1"
android:text="#string/projectName"
android:textSize="16sp"
android:textAppearance="#string/projectName"
android:textColor="#color/text_color"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="35dp"
android:inputType="text"
android:singleLine="true"
android:background="#drawable/editbox_background_normal"
android:layout_weight="1"
android:padding="5dip"
/>
</TableRow>
</TableLayout>

Related

Android button position in table row

I have a table layout with a button in its lowest row:
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name" >
</TextView>
<EditText
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left" >
</EditText>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/frist_name" >
</TextView>
<EditText
android:id="#+id/firstName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left" >
</EditText>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/telephone" >
</TextView>
<EditText
android:id="#+id/telephone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left" >
</EditText>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/userName" >
</TextView>
<EditText
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left" >
</EditText>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/password" >
</TextView>
<EditText
android:id="#+id/password"
android:inputType="textPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left" >
</EditText>
</TableRow>
<TableRow>
<Button
android:id="#+id/saveMasterDataButton"
android:text="#string/save"
android:layout_gravity="center_horizontal|fill_horizontal"
android:textAllCaps="false"
android:visibility="visible"
android:gravity="left|center_vertical|center_horizontal" />
</TableRow>
My Problem ist that the button is always by default out of alignment with the text content in the same column above it by 1 or 2 mm to the right. I fiddled around with various tricks, removing the shade, but the results where never satisfactory.
Here is how this button looks like:Save button out of alignment
Thanks
Matthias

Android - two textviews center sandwich

I have two textviews in a tablelayout and I would like to center both textviews. Horizontally it works but vertically does not.
What's wrong with it?
<TableRow android:id="#+id/TableRow1">
<TextView
android:id="#+id/Feld1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:typeface="sans"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:textSize="40sp" />
</TableRow>
<TableRow android:id="#+id/TableRow2" >
<TextView
android:id="#+id/Feld2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:typeface="serif"
android:gravity="center_horizontal|center_vertical"
android:textSize="50sp" />
</TableRow>
You don't need any of those layout attributes when you're using a table layout. Try removing all of them:
<TableRow android:id="#+id/TableRow1" >
<TextView
android:id="#+id/Field1"
android:layout_gravity="center"
android:typeface="sans"
android:gravity="center_horizontal|center_vertical"
android:textSize="40sp" />
</TableRow>
<TableRow android:id="#+id/TableRow2" >
<TextView
android:id="#+id/Field2"
android:layout_gravity="center"
android:typeface="serif"
android:gravity="center_horizontal|center_vertical"
android:textSize="50sp" />
</TableRow>
Try this..
<!-- android:gravity="center_horizontal" will put the text at center of row horizontally -->
<TableRow
android:id="#+id/TableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="#+id/Feld1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bluelight"
android:text="sample"
android:textSize="20sp"
android:typeface="sans" />
</TableRow>
<!-- Divider/ Separator -->
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:layout_height="2dip"
android:background="#color/grey" />
</TableRow>
<!-- android:gravity="center_horizontal" will put the text at center of row horizontally -->
<TableRow
android:id="#+id/TableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/Feld2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bluelight"
android:text="sample"
android:textSize="20sp"
android:typeface="serif" />
</TableRow>

Alignment issues with TableLayout when adding Buttons

I created a TableLayout for my application. Everything is working fine, but once I add the button image at the bottom of the page the alignment breaks. Here is an image before entering the button image code:
After entering the code for the button images:
My xml layout:
<?xml version="1.0" encoding="utf-8"?>
<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="*"
android:background="#drawable/authenticinfo">
<TableRow
android:id="#+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="18dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="38dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="38dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<ImageView
android:id="#+id/imview"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
/>
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="20dp"
android:gravity="center"
></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow6"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/ProductID1"
android:text="Product ID"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID3"
android:text="92173ad0"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow7"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/ProductID4"
android:text="产品编号 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID5"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID6"
android:text="92173ad0"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow8"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="8dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow9"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/Manf1"
android:text="生产日期 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Manf2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Manf3"
android:text="01 Jan 2012"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow10"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/Exp1"
android:text="有效日期 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Exp2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Exp3"
android:text="01 Jan 2015"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow11"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="8dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow12"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/Mas1"
android:text="马来西亚出口许可证 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Mas2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Mas3"
android:text=""
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow13"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/China1"
android:text="中国的进口许可证 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/China2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/China3"
android:text=""
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow14"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="28dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow15"
>
<ImageView
android:id="#+id/imbutt"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="#+drawable/buttonmainmenuoff"
/>
<ImageView
android:id="#+id/imbutt"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="#+drawable/buttonmainmenuoff"
/>
<ImageView
android:id="#+id/imbutt"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="#+drawable/buttonmainmenuoff"
/>
</TableRow>
</TableLayout>
The layout breaks because the ImageViews that you add at the end stretch the columns where they are placed(for example the second ImageView that you add will stretch the TextView that holds the :). You don't say how you want them placed but one simple thing that you could do is to wrap them in another layout, like LinearLayout like this:
<TableRow android:id="#+id/tableRow15" >
<LinearLayout
android:layout_span="6"
android:gravity="center" >
<ImageView
android:id="#+id/imbutt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
<ImageView
android:id="#+id/imbutt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
<ImageView
android:id="#+id/imbutt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
</LinearLayout>
</TableRow>
Of course you could spread them if you want, with the layout_weight attribute.
As a side note, do you really have 6 columns in your layout(you set the layout_span to 6)? Also , do you use those empty singular TextViews or you just use them as dividers(if this is what you want, then you could consider a simple View element outside the TableRows with the desired height)?

Fitting all of the views onto one table row

I'm trying to put a TextView into my TableView so that it doesn't push the spinner box and the other TextView off of the screen. I've tried changing the layout_width, yet that has not worked. I have also tried changing the layout_width of the TableRow, but that is not working, either. So how can I fit the text of the left-most textView in the row?
<TableLayout android:id="#+id/abilityScoreTable"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:padding="0dip">
<TextView android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:gravity="center" android:textSize="30dip" android:id="#+id/abilityScoreBannerText" android:text="Ability Scores"></TextView>
<TableRow android:layout_width="wrap_content" android:gravity="center" android:id="#+id/tableRow1" android:layout_height="wrap_content">
<TextView android:text="zero" android:id="#+id/StrengthBonusText" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<Spinner android:id="#+id/StrengthSpinner" android:layout_width="10px" android:layout_height="wrap_content" android:entries="#array/string_ability_scores"></Spinner>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:id="#+id/StrengthTextView" android:text="Strength"
android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow2" android:gravity="center">
<Spinner android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="#+id/dexteritySpinner" android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Dexterity" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="#array/string_ability_scores" android:layout_gravity="center"
android:gravity="center" android:id="#+id/TableRow3">
<Spinner android:id="#+id/ConstitutionSpinner"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Constitution" android:textSize="30dip"
android:id="#+id/ConstitutionTextView"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow3" android:gravity="center">
<Spinner android:layout_height="wrap_content"
android:id="#+id/intelligenceSpinner"
android:layout_width="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Intelligence" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow4"
android:gravity="center">
<Spinner android:layout_height="wrap_content"
android:id="#+id/WisdomSpinner" android:layout_width="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:text="Wisdom"
android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow5"
android:gravity="center">
<Spinner android:layout_height="wrap_content"
android:id="#+id/CharismaSpinner" android:layout_width="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView4"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Charisma" android:textSize="30dip"></TextView>
</TableRow>
</TableLayout>
Currently, it looks like this:
On the top-most spinner there's suppose to be a number to the left. I'm trying to squeeze it on to the screen and have all three fit.
im not sure what you want any way check this and tell me is this what you are trying.
if so here is the xml.
<TableRow android:id="#+id/tableRow1">
<TextView android:text="zero" android:id="#+id/StrengthBonusText"></TextView>
<Spinner android:id="#+id/StrengthSpinner" />
<TextView android:id="#+id/StrengthTextView"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Strength" android:textSize="30dip" />
</TableRow>
<TableRow android:id="#+id/tableRow2">
<View android:visibility="invisible" android:layout_height="0dip" />
<Spinner android:id="#+id/dexteritySpinner" />
<TextView android:id="#+id/textView2" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Dexterity" android:textSize="30dip" />
</TableRow>
<TableRow android:id="#+id/TableRow3">
<View android:visibility="invisible" android:layout_height="0dip" />
<Spinner android:id="#+id/ConstitutionSpinner"></Spinner>
<TextView android:id="#+id/ConstitutionTextView"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Constitution" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow3">
<View android:visibility="invisible" android:layout_height="0dip"/>
<Spinner android:id="#+id/intelligenceSpinner"></Spinner>
<TextView android:id="#+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Intelligence" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow4">
<View android:visibility="invisible" android:layout_height="0dip"/>
<Spinner android:id="#+id/WisdomSpinner"></Spinner>
<TextView android:id="#+id/textView3" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Wisdom" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow5">
<View android:visibility="invisible" android:layout_height="0dip"/>
<Spinner android:id="#+id/CharismaSpinner"></Spinner>
<TextView android:id="#+id/textView4" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Charisma" android:textSize="30dip"></TextView>
</TableRow>
Have you tried using a relative layout or is that just not an option? Also I noticed you are mixing px and dip - this is usually not recommended

Android, layout_width and width, alignBaseline, TableLayout and layout_span related questions

[First, sorry, I couldn't come up with a more intelligent question title.]
Okay, hang with me while you read this long post.
I am new to Android, this is my very first dummy Pizza Order application. I am playing with XML layouts and have got some questions.
The editText_CardNo goes out of screen, its column isn't stretching, why? (Image)
[EDIT]
Can I specify a global layout_marginRight for all TableRow?
Resolved
I have aligned elements using alignBaseline but I don't see it working.
In the Crust section i have done layout_span="2" but no use, the second radio button's text still wraps. (Image)
Inner Tables e.g. TableLayout inside TableRow appear really ugly, only left half is visible, also tried with adding layout_span inside TableLayout or the TableRow containing it but no use. (Image)
How can I collapse the subsections e.g. TableLayout inside TableRow using properties?
main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="#+id/scrollView_PizzaOrder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout android:id="#+id/tableLayout_PizzaOrder"
android:shrinkColumns="0"
android:stretchColumns="1"
android:layout_gravity="left"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow android:id="#+id/tableRow_PizzaType"
android:layout_marginTop="10px"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Type"
android:id="#+id/textView_Type"
android:textStyle="bold"
android:layout_alignBaseline="#+id/spinner_Type"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<Spinner android:id="#+id/spinner_Type"
android:drawSelectorOnTop="true"
android:layout_width="200px"
android:layout_height="wrap_content">
</Spinner>
</TableRow>
<TableRow android:id="#+id/tableRow_PizzaSize"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Size"
android:id="#+id/textView_Size"
android:textStyle="bold"
android:layout_alignBaseline="#+id/spinner_Size"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<Spinner android:id="#+id/spinner_Size"
android:drawSelectorOnTop="true"
android:layout_marginBottom="20px"
android:layout_width="200px"
android:layout_height="wrap_content">
</Spinner>
</TableRow>
<TableRow android:id="#+id/tableRow_Crust"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RadioGroup android:id="#+id/radioGroup_Crust"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton android:text="Single Crust"
android:id="#+id/radioButton_SingleCrust"
android:checked="true"
android:layout_span="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RadioButton>
<RadioButton android:text="Double Crust"
android:id="#+id/radiobutton_DoubleCrust"
android:layout_span="2"
android:layout_marginBottom="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RadioButton>
</RadioGroup>
</TableRow>
<TableRow android:id="#+id/tableRow_Toppings"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Extra Toppings?"
android:id="#+id/checkbox_ExtraToppings"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
</TableRow>
<TableRow android:id="#+id/tableRow_ToppingsTable"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout android:id="#+id/tableLayout_Toppings"
android:layout_marginLeft="20px"
android:layout_gravity="left"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow android:id="#+id/tableRow_SelectToppings"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Olives"
android:id="#+id/checkbox_Olives"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<CheckBox android:text="Cheese"
android:id="#+id/checkbox_Cheese"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
</TableRow>
<TableRow android:id="#+id/tableRow_SelectCustomToppings"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Custom"
android:id="#+id/checkbox_Custom"
android:layout_marginRight="10px"
android:layout_alignBaseline="#+id/editText_Custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<EditText android:text=""
android:id="#+id/editText_Custom"
android:singleLine="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
</TableRow>
</TableLayout>
</TableRow>
<TableRow android:id="#+id/tableRow_SeparaterDrinks"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View android:layout_height="2px"
android:background="#884400"
android:layout_span="2"
android:layout_margin="25px" />
</TableRow>
<TableRow android:id="#+id/tableRow_Drinks"
android:layout_span="2"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Drinks?"
android:id="#+id/checkbox_Drinks"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
</TableRow>
<TableRow android:id="#+id/tableRow_DrinksTable"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout android:id="#+id/tableLayout_Drinks"
android:layout_marginLeft="20px"
android:layout_gravity="left"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow android:id="#+id/tableRow_SelectDrinksPepsi"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Drinks links, for now static generation, later use XML and Dynamic Generation -->
<CheckBox android:text="Pepsi"
android:id="#+id/checkbox_Pepsi"
android:checked="true"
android:layout_alignBaseline="#+id/textView_QuantityPepsi"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<TextView android:text="Quantity:"
android:id="#+id/textView_QuanityPepsi"
android:textStyle="bold"
android:layout_alignBaseline="#+id/editText_QuantityPepsi"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text="1"
android:id="#+id/editText_QuantityPepsi"
android:singleLine="true"
android:maxLength="3"
android:numeric="integer"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_SelectDrinksCoke"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Coke"
android:id="#+id/checkbox_Coke"
android:layout_alignBaseline="#+id/textView_QuantityCoke"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<TextView android:text="Quantity:"
android:id="#+id/textView_QuantityCoke"
android:textStyle="bold"
android:layout_alignBaseline="#+id/editText_QuantityCoke"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text="0"
android:id="#+id/editText_QuantityCoke"
android:singleLine="true"
android:maxLength="3"
android:numeric="integer"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_SelectDrinksSprite"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Sprite"
android:id="#+id/checkbox_Sprite"
android:layout_alignBaseline="#+id/textView_QuantitySprite"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<TextView android:text="Quantity:"
android:id="#+id/textView_QuantitySprite"
android:layout_alignBaseline="#+id/editText_QuanitySprite"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text="0"
android:id="#+id/editText_QuantitySprite"
android:singleLine="true"
android:maxLength="3"
android:numeric="integer"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_SelectDrinksMountainDew"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Mirinda"
android:id="#+id/checkbox_Mirinda"
android:layout_alignBaseline="#+id/textView_QuantityMirinda"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<TextView android:text="Quantity:"
android:id="#+id/textView_QuantityMirinda"
android:layout_alignBaseline="#+id/editText_QuantityMirinda"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text="0"
android:id="#+id/editText_QuantityMirinda"
android:singleLine="true"
android:maxLength="3"
android:numeric="integer"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_SelectDrinks7up"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="7up"
android:id="#+id/checkbox_7up"
android:layout_alignBaseline="#+id/textView_Quantity7up"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<TextView android:text="Quantity: "
android:id="#+id/textView_Quantity7up"
android:layout_alignBaseline="#+id/editText_Quantity7up"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text="0"
android:id="#+id/editText_Quantity7up"
android:singleLine="true"
android:maxLength="3"
android:numeric="integer"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
</TableRow>
</TableLayout>
</TableRow>
<TableRow android:id="#+id/tableRow_SeparaterMember"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View android:layout_height="2px"
android:background="#884400"
android:layout_span="2"
android:layout_margin="25px" />
</TableRow>
<TableRow android:id="#+id/tableRow_Member"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="Are you a Member?"
android:id="#+id/checkbox_Member"
android:layout_span="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
</TableRow>
<TableRow android:id="#+id/tableRow_MemberData"
android:layout_marginLeft="20px"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Card #:"
android:id="#+id/textView_CardNo"
android:textStyle="bold"
android:layout_alignBaseline="#+id/editText_CardNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text=""
android:id="#+id/editText_CardNo"
android:singleLine="true"
android:maxLength="8"
android:numeric="integer"
android:layout_width="200px"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_SeparaterMemberData"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View android:layout_height="2px"
android:background="#884400"
android:layout_span="2"
android:layout_margin="25px" />
</TableRow>
<TableRow android:id="#+id/tableRow_Name"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Name:"
android:id="#+id/textView_Name"
android:layout_alignBaseline="#+id/editText_Name"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text=""
android:id="#+id/editText_Name"
android:singleLine="true"
android:maxLength="35"
android:layout_width="200px"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_CellNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Cell:"
android:id="#+id/textView_Cell"
android:textStyle="bold"
android:layout_alignBaseline="#+id/editText_Cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text=""
android:id="#+id/editText_Cell"
android:singleLine="true"
android:phoneNumber="true"
android:maxLength="15"
android:layout_width="200px"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_Address"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Address:"
android:id="#+id/textView_Address"
android:textStyle="bold"
android:layout_alignBaseline="#+id/editText_Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:text=""
android:id="#+id/editText_Address"
android:singleLine="true"
android:maxLength ="200"
android:layout_width="200px"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow android:id="#+id/tableRow_PlaceOrder"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:text="Place Order!"
android:id="#+id/button_PlaceOrder"
android:onClick="placeOrder"
android:layout_column="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</TableRow>
</TableLayout>
</ScrollView>
layout_alignBaseline is for RelativeLayout only. LinearLayout (and therefore TableLayout) perform baseline alignment by default.
The layout_span needs to go on the RadioGroup, not the RadioButtons.
The editText_CardNo goes out of screen because you set its width to android:layout_width="200px". This is too large. The column is stretched only when smaller than the screen. You want it to shrink. You can set a column both shrinkable AND stretchable.
How can i collapse the subsections e.g. TableLayout inside TableRow using properties? >> Use android:visibility="gone"

Categories

Resources