edittext inside tablerow android - android

i have a textview and an edittext inside a tablerow..
my problem is when i try to write many chars in edittext then i cant see what i am writing..it seems like problem in width..Any way to make multiline row or scolling edittext while i am writting?
<TableLayout
android:id="#+id/table"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingTop="30dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:layout_below="#id/banner" >
<TableRow>
<TextView
android:id="#+id/username_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="18dip"
android:text="Username"
/>
<EditText
android:id="#+id/entry1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/password_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="18dip"
android:text="Password" />
<EditText
android:id="#+id/entry2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:password="true" />
</TableRow>
</TableLayout>

Have you tried with android:lines/android:maxLines?

Use this its help For You.
<TableLayout android:id="#+id/table" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:stretchColumns="1"
android:layout_below="#+id/banner">
<TableRow>
<TextView android:id="#+id/username_label"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="#fff" android:textSize="18dip" android:text="Username" />
<EditText android:id="#+id/entry1" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<TextView android:id="#+id/password_label"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textColor="#fff" android:textSize="18dip" android:text="Password" />
<EditText android:id="#+id/entry2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:password="true" />
</TableRow>
</TableLayout>

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

How to increase width of particular EditText in Table Raw (Table layout)

I am using Table Layout.
Here i have three EditText's with same width ="200dp".
But i want to increase the size of 3rd EditText.
I made its width="wrap_content" but all other EditText also getting "wrap_content"
How can i increase the width of 3rd EditText with out affecting other EditText's.
This code for 3rd EditText:-
<TableRow
android:gravity="center_horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:id="#+id/addl"
android:text="Address"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:id="#+id/colon"
android:text=":" />
<EditText
android:layout_width="250dp"
android:layout_marginLeft="20dp"
android:id="#+id/et"
android:singleLine="true"/>
</TableRow>
Now i want to increase width of Address EditText only
i think you can achieve this by layout_weight parameter of EditTexts like below
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout12"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#909090"
android:padding="10dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Student ID"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="6" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Class"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Address"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
</TableLayout>
EDIT
This is the outcome
put the property android:stretchColumns="2" in TableLayout
<TableLayout android:stretchColumns="2" ... > .... </TableLayout>

Long text in TextView

I want to display a long text in a TextView. This is my XML:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="#string/text" />
<TextView
android:id="#+id/gender"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="#string/lorem" />
</TableRow>
</TableLayout>
And this is how it looks like:
The long text doesn't fit. What do I have to change?
<TableLayout
android:layout_width="fill_parent"
android:layout_height="100dip"
android:layout_weight="1" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:padding="5dip"
android:text="#string/text" />
<TextView
android:id="#+id/gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="right"
android:text="#string/lorem" />
</TableRow>
</TableLayout>
Depends on the style, that you want to achive: If Its okay to have multible-Lines you can just add in xml
android:singleLine="false"
or
android:lines="2"
If not you can allow to scroll it horizontally with
android:scrollHorizontally="true"

Android XML resource file error

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?

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