Android XML resource file error - android

Hey I am building an app in android and its been going well until today. i made some changes to one of my layout xml files and it doesn't show any errors for the xml page but when my code runs the setContextView() with that layout file it crashes, the error inst very helpful ( run time exception) so i am pretty sure something is wrong with my xml but ive looked for a few hours now and cant figure it out. any help would be appreciated. thanks
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="#+id/createdeerrecordlayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/titlelayout">
<TextView
android:id="#+id/titlelabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/newTrophyTitle"
android:textSize="10pt">
</TextView>
</LinearLayout>
<LinearLayout android:id="#+id/mainlayout"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<ViewFlipper android:id="#+id/viewflipper"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ScrollView android:id="#+id/scrollviewbasicinfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:id="#+id/relativebasicinfo"
android:layout_height="fill_parent">
<EditText
android:id="#+id/deerName"
android:layout_height="wrap_content"
android:hint="#string/newTrophyName"
android:inputType="textPersonName"
android:layout_width="fill_parent"
android:layout_marginRight="20dip"
android:layout_marginLeft="20dip"
android:layout_marginTop="50dip">
</EditText>
<Spinner android:entries="#array/newTrophyBuckScoreTypelist"
android:prompt="#string/newTrophyBuckScoreType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/NewTrophyBuckScoreType"
android:layout_below="#+id/NewTrophyName"
android:layout_alignRight="#+id/NewTrophyName">
</Spinner>
<Spinner android:layout_below="#+id/NewTrophyName"
android:id="#+id/NewTrophyBuckSpecType"
android:layout_height="wrap_content"
android:prompt="#string/newTrophyBuckSpecType"
android:entries="#array/newTrophyBuckSpecTypelist"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip">
</Spinner>
<EditText android:layout_below="#+id/NewTrophyBuckScoreType"
android:id="#+id/NewTrophyComment"
android:layout_height="wrap_content"
android:hint="#string/newTrophyComment"
android:inputType="textMultiLine"
android:lines="5"
android:layout_width="wrap_content"
android:layout_marginRight="20dip"
android:layout_marginLeft="20dip">
</EditText>
<DatePicker android:id="#+id/killDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/NewTrophyComment"
android:layout_alignLeft="#+id/NewTrophyComment"
android:layout_alignRight="#+id/NewTrophyComment"
android:layout_marginRight="20dip"
android:layout_marginLeft="20dip">
</DatePicker>
<Button android:onClick="getPicURLFromGallery"
android:layout_width="wrap_content"
android:text="Upload Picture"
android:id="#+id/getPicButton"
android:layout_height="wrap_content"
android:layout_below="#+id/killDate"
android:layout_alignLeft="#+id/killDate"
android:layout_alignRight="#+id/killDate">
</Button>
</RelativeLayout>
</ScrollView>
<ScrollView android:id="#+id/scrollviewmeasure1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:id="#+id/linearmeasure1"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:id="#+id/tablemeasure1"
android:layout_height="fill_parent"
android:layout_marginTop="30dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:layout_marginBottom="30dip">
<TableRow>
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Right Antler Points"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.EditNumber android:inputType="numberDecimal" android:hint="No. Points on Right Antler" android:layout_height="wrap_content" android:id="#+id/R_A" android:layout_width="wrap_content"></com.stabe.mtb.EditNumber>
</TableRow>
<TableRow>
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Left Antler Points"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.EditNumber android:inputType="numberDecimal" android:hint="No. Points on Left Antler" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="#+id/L_A"></com.stabe.mtb.EditNumber>
</TableRow>
<TableRow>
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tip to Tip Spread"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.SplitMeasure android:layout_height="wrap_content" android:id="#+id/B" android:layout_width="wrap_content"></com.stabe.mtb.SplitMeasure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Greatest Spread"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.SplitMeasure android:layout_width="wrap_content" android:id="#+id/C" android:layout_height="wrap_content"></com.stabe.mtb.SplitMeasure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Inside Spread of Main Beams"
android:textSize="6pt" android:lines="2">
</TextView>
<com.stabe.mtb.SplitMeasure android:layout_width="wrap_content" android:id="#+id/D" android:layout_height="wrap_content"></com.stabe.mtb.SplitMeasure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Spread Credit"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.SplitMeasure android:layout_width="wrap_content" android:id="#+id/SPREAD_CREDIT" android:layout_height="wrap_content"></com.stabe.mtb.SplitMeasure>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<ScrollView android:id="#+id/scrollviewmeasure2"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="#+id/linearmeasure2"
android:layout_height="wrap_content">
<TableView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_marginTop="30dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:layout_marginBottom="30dip"
android:id="#+id/tablemeasure2">
<TableRow>
<TextView
android:id="#+id/columnLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Left"
android:textSize="6pt">
</TextView>
<TextView
android:id="#+id/columnRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Right"
android:textSize="6pt">
</TextView>
</TableRow>
<TableRow>
<TextView
android:id="#+id/mainlabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Main Beam"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/F"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/g1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G1"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/G1"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/g2label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G2"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/G2"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/g3label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G3"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/G3"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/g4label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G4"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/G4"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/g5label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G5"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/G5"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/g6label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G6"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/G6"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/g7label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G7"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/G7"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/h1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H1"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/H1"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/h2label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H2"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/H2"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/h3label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H3"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/H3"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
<TableRow>
<TextView
android:id="#+id/h4label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H4"
android:textSize="6pt">
</TextView>
<com.stabe.mtb.Measure
android:id="#+id/H4"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_width="fill_parent">
</com.stabe.mtb.Measure>
</TableRow>
</TableView>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="#+id/linearsubmit"
android:layout_height="fill_parent">
<TextView
android:id="#+id/SubmitDeerLabel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:text="#string/submitDeerTitleText"
android:textSize="10pt">
</TextView>
<Button
android:id="#+id/SubmitDeerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:onClick="SubmitDeer"/>
<CheckBox android:id="#+id/EmailCheckBox"
android:text="Email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox android:id="#+id/FacebookCheckBox"
android:text="Facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox android:id="#+id/TwitterCheckBox"
android:text="Twitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</ViewFlipper>
</LinearLayout>
</LinearLayout>

I'm not sure why you have TableView and /TableView tags. Should this be TableLayout? This might cause runtime error and not be caught beforehand but without seeing more code, I could not comment further.
Are there any further error messages (from logcat) that point to error?

Related

Including a new image view inside scroll view causing error

i am having a scroll view like this . There is an image view with id="#+id/but_logo_view1 inside that. I wanted to add another image view to right of that. I tried several ways. But am getting a force close error. How can I achieve the desired result. Please help
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/lineartop"
android:layout_marginBottom="50dip"
android:paddingLeft="10dip"
android:paddingRight="10dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center|center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/but_logo_view1"
android:layout_width="60dip"
android:visibility="visible"
android:layout_height="60dip"
android:scaleType="fitXY"
android:src="#drawable/camera" />
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dip"
android:gravity="center" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="User Name"
android:textColor="#000000"
android:textSize="18dip" />
<EditText
android:id="#+id/edit_signup_user"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:maxLength="10"
android:textSize="18dip"
android:padding="3dip"
android:hint="Name"
android:singleLine="true"
android:textColor="#color/black" android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dip"
android:gravity="center" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Email"
android:textColor="#000000"
android:textSize="18dip" />
<EditText
android:id="#+id/edit_signup_email"
android:layout_width="150dip"
android:layout_height="fill_parent"
android:hint="optional"
android:padding="3dip"
android:singleLine="true"
android:textSize="18dip"
android:textColor="#color/black"
android:textColorHint="#858585" android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dip"
android:gravity="center" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Password"
android:textColor="#000000"
android:textSize="18dip" />
<EditText
android:id="#+id/edit_signup_passwd"
android:textSize="18dip"
android:singleLine="true"
android:inputType="number" android:maxLength="4"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:textColor="#color/black"
android:padding="3dip"
/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dip"
android:gravity="center" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Retype Password"
android:textColor="#000000"
android:textSize="18dip" />
<EditText
android:id="#+id/edit_signup_repasswd"
android:textSize="18dip"
android:singleLine="true"
android:inputType="number" android:maxLength="4"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:textColor="#color/black"
android:padding="3dip"
/>
</TableRow>
</TableLayout>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="#+id/but_signup_twitter"
android:layout_width="70dip"
android:layout_height="70dip"
android:background="#drawable/twitter_icon"
android:visibility="invisible" />
<Button
android:id="#+id/but_signup_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/sign_in_unlit" android:typeface="serif" android:layout_marginLeft="20dip" android:layout_marginRight="20dip"/>
<Button
android:id="#+id/but_signup_fb"
android:layout_width="70dip"
android:layout_height="70dip"
android:background="#drawable/facebook_icon" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:gravity="center|right" >
</TableRow>
</LinearLayout>
</ScrollView>
The error may be occurring because it is a LinearLayout, You could try using instead and setting the imageview like this :
<ImageView
android:id="#+id/image2"
android:layout_alignLeft="#+id/but_logo_view1"
android:layout_width="60dip"
android:visibility="visible"
android:layout_height="60dip"
android:scaleType="fitXY"/>
You can then adjust the padding or the x-axis according to how far away you want the image to be.
I hope this helps.
Not sure if the previous poster missed a word in his response, but to use 'layout_alignLeft' you need to use RelativeLayout instead of LinearLayout

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)?

How to get Horizontol as well as the vertical scrollbars in Android's Table Layout

Here is my code :
What i want is just to make scrollbar available in my application so that the overflow text
will be present in the screen.
Here i am using table layout and table row where my content is too long for a row and it will be long for height of screen so how to display horizontal and vertical scrollbar this code is not working
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="horizontal|vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
</TableLayout>
You can try enclosing within both the scrolls like this,
<ScrollView>
<HorizontalScrollView>
<TableLayout>
<TableRow>
//Your Elements Here
</TableRow>
<TableLayout>
</HorizontalScrollView>
</ScrollView>
Use ScrollView. Here is the Reference link. ScrollView
Tutorial Here - http://www.vogella.de/articles/Android/article.html#scrollview
put your table layout inside a Horizontal Scroll view
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="horizontal">
</ScrollView>

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

Aligning columns in TableLayout

If i use this layout, everything is ok
See this Image:
<TableLayout android:id="#+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#000000" android:layout_margin="10dip" android:padding="10dip" >
<TableRow android:id="#+id/row1" android:layout_width="wrap_content" android:layout_height="wrap_content" >
<TextView android:id="#+id/n1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaaaa a aaaaaaaaa:"></TextView>
<TextView android:id="#+id/c1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="15"></TextView>
</TableRow>
<TableRow android:id="#+id/row2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaaaaaa aaaaa:"></TextView>
<TextView android:id="#+id/c2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="12"></TextView>
</TableRow>
<TableRow android:id="#+id/row3" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaa:"></TextView>
<TextView android:id="#+id/c3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="14"></TextView>
</TableRow>
<TableRow android:id="#+id/row4" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaa:"></TextView>
<TextView android:id="#+id/c4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="3" android:text="18"></TextView>
</TableRow>
<TableRow android:id="#+id/row5" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/n5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:text="aaaaaa aaaaaaaa:"></TextView>
<TextView android:id="#+id/c5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_column="2" android:text="70"></TextView>
</TableRow>
</TableLayout>
But if i set android:layout_column="3" for the second textview in the last row, this shows http://www.lukafinzgar.com/nekul.png .
How should i set the attributes to get all the numbers in the third column?
You have to use "android:layout_width" and "android:layout_height" in TableLayout tag only. not anywhere else. And use "android:layout_weight" in each element of TableRow tag to adjust the columns horizontally.Try the below coding.
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView android:id="#+id/cpotl1textview1"
android:layout_weight="0.5"
android:text="Total Outstanding" />
<EditText android:id="#+id/cpotl1edittext1"
android:layout_weight="0.5"
android:inputType="numberDecimal" />
</TableRow>
<TableRow>
<TextView android:id="#+id/cpotl1textview2"
android:layout_weight="0.5"
android:text="Claim Amount" />
<EditText android:id="#+id/cpotl1edittext2"
android:layout_weight="0.5"
android:inputType="numberDecimal" />
</TableRow>
<TableRow>
<TextView android:id="#+id/cpotl1textview3"
android:layout_weight="0.5"
android:text="Select Message" />
<AutoCompleteTextView android:id="#+id/cpotl1autocompletetextview"
android:layout_weight="0.5"
android:hint="Templates" />
</TableRow>
</TableLayout>
Thanks for opportunity.
Try This:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:background="#000000"
android:padding="10dip" >
<TableRow
android:id="#+id/row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n1"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaa a aaaaaaaaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="15"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n2"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaaa aaaaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="12"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n3"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="14"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n4"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="18"
android:textColor="#ffffff" >
</TextView>
</TableRow>
<TableRow
android:id="#+id/row5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/n5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaa aaarrrrrrraaaaa:"
android:textColor="#ffffff" >
</TextView>
<TextView
android:id="#+id/c5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:text="70"
android:textColor="#ffffff" >
</TextView>
</TableRow>
</TableLayout>

Categories

Resources