When I open a new activity called 'reservations', the activity focuses directly on the center of the scrollview. I tried setting the focusable(true) to the top part only but when I do this the edittext boxes are no longer allowed to to be used on touch.
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="vertical"
tools:context="com.first.android.spaseafoods.Contact"
tools:ignore="MergeRootFrame" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="vertical" >
<android.support.v7.widget.Space
android:id="#+id/space1"
android:layout_width="20sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Please fill out the following information if you would like to make a reservation, you will receive confirmation within 24 hours."
android:textColor="#ffffff"
android:textSize="20sp" />
<android.support.v7.widget.Space
android:id="#+id/space2"
android:layout_width="20sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Name *"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<EditText
android:id="#+id/editTextName"
android:layout_width="330dp"
android:layout_height="30dp"
android:background="#drawable/rounded_edittext"
android:ems="10" />
<android.support.v7.widget.Space
android:id="#+id/space3"
android:layout_width="20sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Phone *"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<EditText
android:id="#+id/editTextPhone"
android:layout_width="330dp"
android:layout_height="30dp"
android:background="#drawable/rounded_edittext"
android:ems="10" />
<android.support.v7.widget.Space
android:id="#+id/space4"
android:layout_width="20sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="E-mail"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<EditText
android:id="#+id/editTextEmail"
android:layout_width="330dp"
android:layout_height="30dp"
android:background="#drawable/rounded_edittext"
android:ems="10"
android:inputType="textEmailAddress" />
<android.support.v7.widget.Space
android:id="#+id/space5"
android:layout_width="20sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Number of people"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<EditText
android:id="#+id/editTextPeople"
android:layout_width="75sp"
android:layout_height="30sp"
android:background="#drawable/rounded_edittext"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<android.support.v7.widget.Space
android:id="#+id/space6"
android:layout_width="20sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reservation Date *"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<EditText
android:id="#+id/editTextDate"
android:layout_width="150sp"
android:layout_height="30sp"
android:background="#drawable/rounded_edittext"
android:ems="10"
android:inputType="date" >
<requestFocus />
</EditText>
<android.support.v7.widget.Space
android:id="#+id/space7"
android:layout_width="40sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reservation Time *"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<EditText
android:id="#+id/editTextTime"
android:layout_width="150sp"
android:layout_height="30sp"
android:background="#drawable/rounded_edittext"
android:ems="10"
android:inputType="time" >
<requestFocus />
</EditText>
<android.support.v7.widget.Space
android:id="#+id/space8"
android:layout_width="20sp"
android:layout_height="30sp" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comments"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<EditText
android:id="#+id/editTextComments"
android:layout_width="330dp"
android:layout_height="100dp"
android:background="#drawable/rounded_edittext"
android:ems="10"
android:inputType="textMultiLine"
android:lines="4" />
<android.support.v7.widget.Space
android:id="#+id/space9"
android:layout_width="20sp"
android:layout_height="30sp" />
<Button
android:id="#+id/button1"
android:layout_width="330dp"
android:layout_height="60dp"
android:onClick="sendFeedback"
android:text="Submit"
android:textColor="#ffffff"
android:textSize="25sp" />
</LinearLayout>
</ScrollView>
Related
Inside my xml file i put a scroll view. But it doesn't shows in my program. I was confused because i checked for any color problems. Here is my xml file, can anyone specifies the reason it doesn't shown at there?
Please note: some characters from textview and edittext are removed due to character limitation by stack overflow.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="#+id/rtop"
android:layout_width="wrap_content"
android:background="#drawable/top_transperant_bg" >
<Button
android:id="#+id/imageViewlogo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView3"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#android:color/transparent"
android:drawableTop="#drawable/icon_home"
android:paddingTop="5dp"
android:text="Your Home"
android:textColor="#c1c1c1" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
/>
</RelativeLayout>
<RelativeLayout
android:background="#drawable/bg_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rtop"
android:layout_above="#+id/Rbottom"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingTop="10dp"
>
<ScrollView
android:id="#+id/s1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/midle"
android:scrollbars="none"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/Rcentre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rela"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText3"
/>
<EditText
android:id="#+id/editText1"
android:layout_width="#dimen/Edittextwidth"
android:layout_height="#dimen/Edittextheight"
android:layout_centerHorizontal="true"
android:layout_alignParentRight="true"
android:capitalize="words"
android:textSize="#dimen/font_size_normal" >
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText1"
android:layout_marginTop="5dp"
android:inputType="textMultiLine"
android:maxLines="6"
android:text="Contact Person" />
<EditText
android:id="#+id/editText2"
android:layout_width="#dimen/Edittextwidth"
android:layout_height="#dimen/Edittextheight"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView2"
android:layout_marginTop="5dp"
android:background="#drawable/regtextfieldborder"
android:ems="10"
android:padding="5dp"
android:capitalize="words"
android:singleLine="true"
android:layout_alignParentRight="true"
android:textSize="#dimen/font_size_normal" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/checkBox3"
android:layout_marginTop="5dp"
android:text="Home Email" />
<EditText
android:id="#+id/editText4"
android:layout_width="#dimen/Edittextwidth"
android:layout_height="#dimen/Edittextheight"
android:layout_alignLeft="#+id/textView5"
android:layout_below="#+id/textView5"
android:layout_marginTop="5dp"
android:background="#drawable/regtextfieldborder"
android:editable="false"
android:ems="10"
android:focusable="false"
android:padding="5dp"
android:singleLine="true"
android:layout_alignParentRight="true"
android:textSize="#dimen/font_size_normal" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/checkBox1"
android:layout_marginTop="5dp"
android:text="Home Phone Number" />
<EditText
android:id="#+id/editText9"
android:layout_width="#dimen/Edittextwidth"
android:layout_height="#dimen/Edittextheight"
android:layout_alignLeft="#+id/textView9"
android:layout_below="#+id/textView9"
<EditText
android:id="#+id/editText10"
android:layout_width="#dimen/Edittextwidth"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:gravity="top"
android:imeOptions="actionDone"
android:lines="6"
android:maxLines="10"
android:padding="5dp"
android:scrollHorizontally="false"
android:layout_alignParentRight="true"
android:inputType="textCapSentences|textMultiLine"
android:scrollbars="vertical"
android:textSize="#dimen/font_size_normal" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText10"
android:layout_below="#+id/editText10"
android:layout_marginTop="5dp"
android:text="Residence Type" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="#dimen/Edittextwidth"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView6"
android:layout_alignParentRight="true"
android:layout_alignRight="#+id/editText10"
android:layout_below="#+id/textView6"
android:layout_marginTop="5dp"
android:background="#drawable/combo_bx"
android:padding="5dp"
android:popupBackground="#android:color/transparent"
android:spinnerMode="dropdown" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
/>
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/textView4"
android:layout_below="#+id/editText4"
android:layout_marginTop="5dp"
android:text="Share my email address with other homeowners"
android:textColor="#FF0000"
android:visibility="gone"
android:textSize="#dimen/font_size_normal" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/editText9"
android:layout_below="#+id/editText9"
android:layout_marginTop="5dp"
android:text="Show my info to other residents"
android:textColor="#FFFFFF"
android:textSize="#dimen/font_size_normal" />
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText2"
android:layout_marginTop="5dp"
android:text="Share my contact with other homeowners"
android:textColor="#FF0000"
android:visibility="gone"
android:textSize="#dimen/font_size_normal" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/spinner1"
android:layout_marginRight="40dp"
android:clickable="true"
android:text="Next>>"
android:visibility="gone" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinner1"
android:layout_marginTop="5dp" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Vehicle Status "
android:textColor="#c1c1c1" />
<RadioButton
android:id="#+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/view1"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/radioButton2"
android:layout_toRightOf="#+id/textView5"
android:layout_marginBottom="5dp"
android:text=" Yes" />
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#+id/textView5"
android:layout_marginTop="5dp"
android:background="#c1c1c1" />
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view1"
android:layout_marginTop="5dp" >
<LinearLayout
android:id="#+id/firstvehicle"
android:layout_width="282dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="Make "
android:textColor="#c1c1c1" />
<EditText
android:id="#+id/vehiclemake1"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/regtextfieldborder"
android:ems="9"
android:padding="5dp"
android:inputType="textCapSentences"
android:textSize="#dimen/font_size_normal"
android:singleLine="true" />
<TextView
android:id="#+id/textView2more1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:background="#drawable/more_button"
android:clickable="true"
android:visibility="gone"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="Model "
android:textColor="#c1c1c1" />
<EditText
android:id="#+id/vehiclemodel1"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/regtextfieldborder"
android:ems="9"
android:layout_alignParentRight="true"
android:textSize="#dimen/font_size_normal"
android:inputType="textCapSentences"
android:padding="5dp"
android:singleLine="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="License"
android:textColor="#c1c1c1" />
<EditText
android:id="#+id/vehiclenumber1"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/regtextfieldborder"
android:ems="9"
android:padding="5dp"
android:inputType="textCapWords"
android:layout_alignParentRight="true"
android:textSize="#dimen/font_size_normal"
android:singleLine="true" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearcolour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="50dp"
android:layout_height="wrap_content"
android:textColor="#c1c1c1"
android:text="Color " />
<EditText
android:id="#+id/colour"
android:singleLine="true"
android:ems="9" />
<TextView
android:id="#+id/textView2more"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginLeft="5dp"
android:background="#drawable/more_button"
android:clickable="true"
android:gravity="center" />
</LinearLayout>
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#c1c1c1" />
</LinearLayout>
<LinearLayout
android:id="#+id/mainLinearLayouts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/firstvehicle"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_below="#+id/mainLinearLayouts"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="#drawable/buttoncolour"
android:onClick="submit"
android:text="Submit"
android:visibility="gone"
android:textColor="#c1c1c1" />
</RelativeLayout>
<RadioButton
android:id="#+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout1"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="20dp"
android:text=" No" />
</RelativeLayout>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView7"
android:layout_alignLeft="#+id/textView1"
android:text="Address" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_alignRight="#+id/editText1"
android:layout_below="#+id/textView8"
android:layout_marginTop="5dp"
android:background="#drawable/regtextfieldborder"
android:ems="10"
android:gravity="top"
android:inputType="textMultiLine|textCapSentences"
android:lines="5"
android:maxLines="6"
android:padding="5dp"
android:layout_centerHorizontal="true"
android:layout_alignParentRight="true"
android:textSize="#dimen/font_size_normal" >
</EditText>
<ImageView
android:id="#+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#c1c1c1"
android:padding="2dp"
android:src="#drawable/profile_image" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/midle"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginTop="5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<Button
android:id="#+id/buttonsubmit"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:background="#drawable/buttoncolour"
android:gravity="center"
android:textColor="#c1c1c1"
android:text="Submit"/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/Rbottom"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
</RelativeLayout>
</RelativeLayout>
You used Some illegal character with XML
Also You have used some Empty views. That will not display proper output. and Each and every view must have height and width attribute in it. You missed in some.
I corrected some errors. This Might can help.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rtop"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#ff6700" >
<RelativeLayout
android:id="#+id/rtop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#80ff6700" >
<Button
android:id="#+id/imageViewlogo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView3"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#android:color/transparent"
android:drawableTop="#drawable/ic_launcher"
android:paddingTop="5dp"
android:text="Your Home"
android:textColor="#c1c1c1" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/Rbottom"
android:layout_below="#+id/rtop"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#20ff6700"
android:paddingTop="10dp" >
<ScrollView
android:id="#+id/s1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical"
android:scrollbars="none" >
<LinearLayout
android:id="#+id/Rcentre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rela"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText3" />
<EditText
android:id="#+id/editText1"
android:layout_width="80dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:capitalize="words"
android:textSize="10sp" >
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText1"
android:layout_marginTop="5dp"
android:inputType="textMultiLine"
android:maxLines="6"
android:text="Contact Person" />
<EditText
android:id="#+id/editText2"
android:layout_width="80sp"
android:layout_height="20sp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView2"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:capitalize="words"
android:ems="10"
android:padding="5dp"
android:singleLine="true"
android:textSize="10sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/checkBox3"
android:layout_marginTop="5dp"
android:text="Home Email" />
<EditText
android:id="#+id/editText4"
android:layout_width="80dp"
android:layout_height="20dp"
android:layout_alignLeft="#+id/textView5"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView5"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:editable="false"
android:ems="10"
android:focusable="false"
android:padding="5dp"
android:singleLine="true"
android:textSize="10sp" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/checkBox1"
android:layout_marginTop="5dp"
android:text="Home Phone Number" />
<EditText
android:id="#+id/editText9"
android:layout_width="80dp"
android:layout_height="20dp"
android:layout_alignLeft="#+id/textView9"
android:layout_below="#+id/textView9" />
<EditText
android:id="#+id/editText10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:focusableInTouchMode="true"
android:gravity="top"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textMultiLine"
android:lines="6"
android:maxLines="10"
android:padding="5dp"
android:scrollHorizontally="false"
android:scrollbars="vertical"
android:textSize="10dp" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText10"
android:layout_below="#+id/editText10"
android:layout_marginTop="5dp"
android:text="Residence Type" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView6"
android:layout_alignParentRight="true"
android:layout_alignRight="#+id/editText10"
android:layout_below="#+id/textView6"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:padding="5dp"
android:popupBackground="#android:color/transparent"
android:spinnerMode="dropdown" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/textView4"
android:layout_below="#+id/editText4"
android:layout_marginTop="5dp"
android:text="Share my email address with other homeowners"
android:textColor="#FF0000"
android:textSize="10dp"
android:visibility="gone" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/editText9"
android:layout_below="#+id/editText9"
android:layout_marginTop="5dp"
android:text="Show my info to other residents"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText2"
android:layout_marginTop="5dp"
android:text="Share my contact with other homeowners"
android:textColor="#FF0000"
android:textSize="10sp"
android:visibility="gone" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/spinner1"
android:layout_marginRight="40dp"
android:clickable="true"
android:text="Next>>"
android:visibility="gone" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinner1"
android:layout_marginTop="5dp" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Vehicle Status "
android:textColor="#c1c1c1" />
<RadioButton
android:id="#+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/view1"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp"
android:layout_toLeftOf="#+id/radioButton2"
android:layout_toRightOf="#+id/textView5"
android:text=" Yes" />
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#+id/textView5"
android:layout_marginTop="5dp"
android:background="#c1c1c1" />
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view1"
android:layout_marginTop="5dp" >
<LinearLayout
android:id="#+id/firstvehicle"
android:layout_width="282dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="Make "
android:textColor="#c1c1c1" />
<EditText
android:id="#+id/vehiclemake1"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:ems="9"
android:inputType="textCapSentences"
android:padding="5dp"
android:singleLine="true"
android:textSize="10sp" />
<TextView
android:id="#+id/textView2more1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:background="#ff6700"
android:clickable="true"
android:gravity="center"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="Model "
android:textColor="#c1c1c1" />
<EditText
android:id="#+id/vehiclemodel1"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:ems="9"
android:inputType="textCapSentences"
android:padding="5dp"
android:singleLine="true"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="License"
android:textColor="#c1c1c1" />
<EditText
android:id="#+id/vehiclenumber1"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:ems="9"
android:inputType="textCapWords"
android:padding="5dp"
android:singleLine="true"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearcolour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="Color "
android:textColor="#c1c1c1" />
<EditText
android:id="#+id/colour"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:ems="9"
android:singleLine="true" />
<TextView
android:id="#+id/textView2more"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginLeft="5dp"
android:background="#ff6700"
android:clickable="true"
android:gravity="center" />
</LinearLayout>
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#c1c1c1" />
</LinearLayout>
<LinearLayout
android:id="#+id/mainLinearLayouts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/firstvehicle"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_below="#+id/mainLinearLayouts"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:onClick="submit"
android:text="Submit"
android:textColor="#c1c1c1"
android:visibility="gone" />
</RelativeLayout>
<RadioButton
android:id="#+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout1"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="20dp"
android:text=" No" />
</RelativeLayout>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView7"
android:text="Address" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_alignParentRight="true"
android:layout_alignRight="#+id/editText1"
android:layout_below="#+id/textView8"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="#ff6700"
android:ems="10"
android:gravity="top"
android:inputType="textMultiLine|textCapSentences"
android:lines="5"
android:maxLines="6"
android:padding="5dp"
android:textSize="10sp" >
</EditText>
<ImageView
android:id="#+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#c1c1c1"
android:padding="2dp"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/midle"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp" >
<Button
android:id="#+id/buttonsubmit"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:background="#ff6700"
android:gravity="center"
android:text="Submit"
android:textColor="#c1c1c1" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/Rbottom"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
This scrollview freezes after a few seconds. How can I solve it? This works perfectly fine but it freezes after a while.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent" >
<AbsoluteLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/acc_stngs"
android:paddingTop="50dip"
android:paddingBottom="50dip"
>
<TextView
android:id="#+id/textView1"
android:layout_width="162dp"
android:layout_height="50dip"
android:layout_x="17dp"
android:layout_y="95dp"
android:text="Name:"
android:textColor="#ff333333"
android:textSize="20dp"/>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="85dp"
android:layout_y="95dp"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="160dp"
android:text="Surname:"
android:textColor="#ff333333"
android:textSize="20dp" />
<EditText
android:id="#+id/editText2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="105dp"
android:layout_y="160dp"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="280dp"
android:text="E-mail:"
android:textColor="#ff333333"
android:textSize="20dp" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="87dp"
android:layout_y="280dp"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="380dp"
android:text="Address:"
android:textColor="#ff333333"
android:textSize="20dp" />
<EditText
android:id="#+id/editText4"
android:layout_width="278dp"
android:layout_height="96dp"
android:layout_x="19dp"
android:layout_y="450dp"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="630dp"
android:text="Current Password:"
android:textColor="#ff333333"
android:textSize="20dp" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="655dp"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="710dp"
android:text="New Password:"
android:textColor="#ff333333"
android:textSize="20dp" />
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="735dp"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="790dp"
android:text="Confirm Password:"
android:textColor="#ff333333"
android:textSize="20dp" />
<EditText
android:id="#+id/editText7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="815dp"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="#+id/widget46"
android:layout_width="135dp"
android:layout_height="wrap_content"
android:layout_x="17dp"
android:layout_y="900dp"
android:background="#ff990033"
android:onClick="LogOutUser"
android:text="Log Out"
android:textColor="#ffffffff" />
<Button
android:id="#+id/widget46"
android:layout_width="135dp"
android:layout_height="wrap_content"
android:layout_x="170dp"
android:layout_y="900dp"
android:background="#ff000099"
android:onClick=""
android:text="Save"
android:textColor="#ffffffff" />
</AbsoluteLayout>
</ScrollView>
I am trying to make my activity screen where there is a form to be filled scrollable but unfortunately, when I tried it crashed the app. I have the following xml for that activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="19dp"
android:text="#string/discountLocationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignRight="#+id/shopCity"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView5"
android:layout_below="#+id/shopDiscount"
android:layout_marginTop="21dp"
android:text="#string/discountDurationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopDiscountDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/shopDiscount"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/shopDiscount"
android:layout_alignParentRight="true"
android:text="#string/discountRateLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView6"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:background="#drawable/roundbutton"
android:text="#string/discountPublishButtonLabel"
android:textColor="#color/white"
android:onClick="SubmitData"
android:width="250dp" />
<EditText
android:id="#+id/shopCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView4"
android:layout_alignRight="#+id/shopName"
android:ems="10"
android:inputType="text" >
</EditText>
<EditText
android:id="#+id/shopDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/shopLocation"
android:layout_below="#+id/shopLocation"
android:layout_marginTop="14dp"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/shopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:ems="10"
android:inputType="text">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/categoriesSpinner"
android:layout_alignRight="#+id/textView2"
android:text="#string/discountCategoryLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Spinner
android:id="#+id/categoriesSpinner"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_above="#+id/shopName"
android:layout_alignLeft="#+id/button1"
android:layout_marginBottom="16dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView2"
android:layout_marginTop="206dp"
android:text="#string/discountCityLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/shopCity"
android:layout_alignLeft="#+id/textView5"
android:layout_marginBottom="18dp"
android:text="#string/discountShopLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView1"
android:layout_marginTop="14dp"
android:gravity="right"
android:text="#string/addDiscountMsg"
android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textDirection="anyRtl" />
</RelativeLayout>
And when I tried to add the following after defining RelativeLayout and before closing RelativeLayout, it broke the app immediately when I run it.
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
...........
</ScrollView>
How can I make it scrollable?
Your app crashes because ScrollView can host only one direct child.
Direct from official documentation:
Layout container for a view hierarchy that can be scrolled by the
user, allowing it to be larger than the physical display. A ScrollView
is a FrameLayout, meaning you should place one child in it containing
the entire contents to scroll; this child may itself be a layout
manager with a complex hierarchy of objects. A child that is often
used is a LinearLayout in a vertical orientation, presenting a
vertical array of top-level items that the user can scroll through.
Look this http://developer.android.com/reference/android/widget/ScrollView.html.
To solve your xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="19dp"
android:text="#string/discountLocationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignRight="#+id/shopCity"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView5"
android:layout_below="#+id/shopDiscount"
android:layout_marginTop="21dp"
android:text="#string/discountDurationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopDiscountDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/shopDiscount"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/shopDiscount"
android:layout_alignParentRight="true"
android:text="#string/discountRateLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView6"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:background="#drawable/roundbutton"
android:text="#string/discountPublishButtonLabel"
android:textColor="#color/white"
android:onClick="SubmitData"
android:width="250dp" />
<EditText
android:id="#+id/shopCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView4"
android:layout_alignRight="#+id/shopName"
android:ems="10"
android:inputType="text" />
<EditText
android:id="#+id/shopDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/shopLocation"
android:layout_below="#+id/shopLocation"
android:layout_marginTop="14dp"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/shopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:ems="10"
android:inputType="text">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/categoriesSpinner"
android:layout_alignRight="#+id/textView2"
android:text="#string/discountCategoryLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Spinner
android:id="#+id/categoriesSpinner"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_above="#+id/shopName"
android:layout_alignLeft="#+id/button1"
android:layout_marginBottom="16dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView2"
android:layout_marginTop="206dp"
android:text="#string/discountCityLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/shopCity"
android:layout_alignLeft="#+id/textView5"
android:layout_marginBottom="18dp"
android:text="#string/discountShopLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView1"
android:layout_marginTop="14dp"
android:gravity="right"
android:text="#string/addDiscountMsg"
android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textDirection="anyRtl" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Do it like this , it will work :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="19dp"
android:text="#string/discountLocationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignRight="#+id/shopCity"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView5"
android:layout_below="#+id/shopDiscount"
android:layout_marginTop="21dp"
android:text="#string/discountDurationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopDiscountDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/shopDiscount"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/shopDiscount"
android:layout_alignParentRight="true"
android:text="#string/discountRateLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView6"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:background="#drawable/roundbutton"
android:text="#string/discountPublishButtonLabel"
android:textColor="#color/white"
android:onClick="SubmitData"
android:width="250dp" />
<EditText
android:id="#+id/shopCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView4"
android:layout_alignRight="#+id/shopName"
android:ems="10"
android:inputType="text" >
</EditText>
<EditText
android:id="#+id/shopDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/shopLocation"
android:layout_below="#+id/shopLocation"
android:layout_marginTop="14dp"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/shopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:ems="10"
android:inputType="text">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/categoriesSpinner"
android:layout_alignRight="#+id/textView2"
android:text="#string/discountCategoryLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Spinner
android:id="#+id/categoriesSpinner"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_above="#+id/shopName"
android:layout_alignLeft="#+id/button1"
android:layout_marginBottom="16dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView2"
android:layout_marginTop="206dp"
android:text="#string/discountCityLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/shopCity"
android:layout_alignLeft="#+id/textView5"
android:layout_marginBottom="18dp"
android:text="#string/discountShopLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView1"
android:layout_marginTop="14dp"
android:gravity="right"
android:text="#string/addDiscountMsg"
android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textDirection="anyRtl" />
</RelativeLayout>
</ScrollView>
Hope help you
I think you must enclose your relative layout in your scrollview ( before defining and after closing ) .
EDIT : You must also enclose your relative layout in Liner Layout
ex :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
</RelativeLayout>
</LinearLayout>
</SrcollView>
my xml goes as shown below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/form_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"
android:orientation="vertical"
android:overScrollMode="ifContentScrolls"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical" >
<Spinner
android:id="#+id/formulae"
android:layout_width="200dp"
android:layout_height="60dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="#color/LightSkyBlue"
android:dropDownWidth="wrap_content"
android:entries="#array/formulas"
android:gravity="center"
android:paddingLeft="0dp"
android:textAlignment="center" />
<EditText
android:id="#+id/k2_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/al"
android:layout_alignRight="#+id/al_editText"
android:layout_alignTop="#+id/k2"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<TextView
android:id="#+id/k1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/dr"
android:layout_marginLeft="24dp"
android:layout_marginTop="28dp"
android:text="#string/K1"
android:textColor="#color/white"
android:textSize="25sp" />
<EditText
android:id="#+id/k1_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/k2"
android:layout_alignLeft="#+id/k2_editText"
android:layout_alignRight="#+id/k2_editText"
android:layout_alignTop="#+id/k1"
android:background="#drawable/edit_text_holo_light"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<TextView
android:id="#+id/dr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/formulae"
android:layout_below="#+id/formulae"
android:layout_marginTop="14dp"
android:layout_toLeftOf="#+id/k1_editText"
android:ems="10"
android:gravity="center"
android:text="#string/dr"
android:textColor="#color/White"
android:textSize="25sp" />
<TextView
android:id="#+id/k2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/k1"
android:layout_below="#+id/k1"
android:layout_marginTop="38dp"
android:text="#string/K2"
android:textColor="#color/White"
android:textSize="25sp" />
<TextView
android:id="#+id/al"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/k2"
android:layout_below="#+id/k2"
android:layout_marginTop="38dp"
android:text="#string/AL"
android:textColor="#color/White"
android:textSize="25sp" />
<EditText
android:id="#+id/al_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/formulae"
android:layout_alignTop="#+id/al"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<EditText
android:id="#+id/al_const_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/al_const"
android:layout_alignRight="#+id/al_editText"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<EditText
android:id="#+id/dr_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/k1_editText"
android:layout_alignRight="#+id/formulae"
android:layout_alignTop="#+id/dr"
android:ems="10"
android:inputType="numberDecimal|numberSigned"
android:textColor="#color/White"
android:textSize="15sp" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/al_const"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/al"
android:layout_below="#+id/al_editText"
android:layout_marginTop="43dp"
android:text="#string/Rx"
android:textColor="#color/White"
android:textSize="20sp" />
<Button
android:id="#+id/result"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#color/LightSkyBlue"
android:text="#string/Result"
android:textSize="25sp" />
</RelativeLayout>
graphical layout :
I want the fields from DR to A-const to be scrollable. I searched every possible solution in here and elsewhere but in vain. Being a beginner in android i seek help here
Try this :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="#+id/form_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/black" >
<Spinner
android:id="#+id/formulae"
android:layout_width="200dp"
android:layout_height="60dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="#color/LightSkyBlue"
android:dropDownWidth="wrap_content"
android:entries="#array/formulas"
android:gravity="center"
android:paddingLeft="0dp"
android:textAlignment="center" />
<EditText
android:id="#+id/k2_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/al"
android:layout_alignRight="#+id/al_editText"
android:layout_alignTop="#+id/k2"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<TextView
android:id="#+id/k1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/dr"
android:layout_marginLeft="24dp"
android:layout_marginTop="28dp"
android:text="#string/K1"
android:textColor="#color/white"
android:textSize="25sp" />
<EditText
android:id="#+id/k1_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/k2"
android:layout_alignLeft="#+id/k2_editText"
android:layout_alignRight="#+id/k2_editText"
android:layout_alignTop="#+id/k1"
android:background="#drawable/edit_text_holo_light"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<TextView
android:id="#+id/dr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/formulae"
android:layout_below="#+id/formulae"
android:layout_marginTop="14dp"
android:layout_toLeftOf="#+id/k1_editText"
android:ems="10"
android:gravity="center"
android:text="#string/dr"
android:textColor="#color/White"
android:textSize="25sp" />
<TextView
android:id="#+id/k2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/k1"
android:layout_below="#+id/k1"
android:layout_marginTop="38dp"
android:text="#string/K2"
android:textColor="#color/White"
android:textSize="25sp" />
<TextView
android:id="#+id/al"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/k2"
android:layout_below="#+id/k2"
android:layout_marginTop="38dp"
android:text="#string/AL"
android:textColor="#color/White"
android:textSize="25sp" />
<EditText
android:id="#+id/al_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/formulae"
android:layout_alignTop="#+id/al"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<EditText
android:id="#+id/al_const_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/al_const"
android:layout_alignRight="#+id/al_editText"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:onClick="#drawable/textfield_activated_holo_light"
android:textColor="#color/White"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<EditText
android:id="#+id/dr_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/k1_editText"
android:layout_alignRight="#+id/formulae"
android:layout_alignTop="#+id/dr"
android:ems="10"
android:inputType="numberDecimal|numberSigned"
android:textColor="#color/White"
android:textSize="15sp" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/al_const"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/al"
android:layout_below="#+id/al_editText"
android:layout_marginTop="43dp"
android:text="#string/Rx"
android:textColor="#color/White"
android:textSize="20sp" />
<Button
android:id="#+id/result"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#color/LightSkyBlue"
android:text="#string/Result"
android:textSize="25sp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Thanks.
Try this...it works fine for me
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/form_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:overScrollMode="ifContentScrolls"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical" >
<Spinner
android:id="#+id/formulae"
android:layout_width="200dp"
android:layout_height="60dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:dropDownWidth="wrap_content"
android:gravity="center"
android:paddingLeft="0dp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/result"
android:layout_below="#+id/formulae" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/formulae" >
<EditText
android:id="#+id/k2_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/al"
android:layout_alignRight="#+id/al_editText"
android:layout_alignTop="#+id/k2"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<TextView
android:id="#+id/k1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/dr"
android:layout_marginLeft="24dp"
android:layout_marginTop="28dp"
android:text="K1"
android:textSize="25sp" />
<EditText
android:id="#+id/k1_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/k2"
android:layout_alignLeft="#+id/k2_editText"
android:layout_alignRight="#+id/k2_editText"
android:layout_alignTop="#+id/k1"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<TextView
android:id="#+id/dr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/formulae"
android:layout_below="#+id/formulae"
android:layout_marginTop="14dp"
android:layout_toLeftOf="#+id/k1_editText"
android:ems="10"
android:gravity="center"
android:text="dr"
android:textSize="25sp" />
<TextView
android:id="#+id/k2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/k1"
android:layout_below="#+id/k1"
android:layout_marginTop="38dp"
android:text="K2"
android:textSize="25sp" />
<TextView
android:id="#+id/al"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/k2"
android:layout_below="#+id/k2"
android:layout_marginTop="38dp"
android:text="AL"
android:textSize="25sp" />
<EditText
android:id="#+id/al_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/formulae"
android:layout_alignTop="#+id/al"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<EditText
android:id="#+id/al_const_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/al_const"
android:layout_alignRight="#+id/al_editText"
android:layout_marginLeft="120dp"
android:ems="10"
android:enabled="true"
android:inputType="numberDecimal"
android:textSize="15sp"
android:visibility="visible"
android:width="100dp" />
<EditText
android:id="#+id/dr_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/k1_editText"
android:layout_alignRight="#+id/formulae"
android:layout_alignTop="#+id/dr"
android:ems="10"
android:inputType="numberDecimal|numberSigned"
android:textSize="15sp" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/al_const"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/al"
android:layout_below="#+id/al_editText"
android:layout_marginTop="43dp"
android:text="Rx"
android:textSize="20sp" />
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/result"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Result"
android:textSize="25sp" />
</RelativeLayout>
The contents of my android app are increasing from the layout portion, but I want to wrap the layout as contents are increasing. Can I adjust my all contents on a single relative layout or is this possible on any other layout?
Layout Code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/ttl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ep"
android:textColor="#00ccff"
android:textSize="18sp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginLeft="70dp"
android:layout_marginTop="15dp"
/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/eprice"
android:layout_marginTop="64dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/ep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:text="#string/epval"
android:inputType="text"
android:layout_marginLeft="245dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/molcal"
android:layout_marginTop="100dp"
android:textColor="#00cc00"
android:textSize="18sp"
android:textStyle="bold"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/molfac"
android:layout_marginTop="135dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/molex"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="122dp"
android:text="#string/molex"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/frght"
android:layout_marginTop="180dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/frght"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="167dp"
android:text="#string/frghtport"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/whlfrg"
android:layout_marginTop="225dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/whar"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="212dp"
android:text="#string/whlfrgval"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/storage"
android:layout_marginTop="270dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/storage"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="257dp"
android:text="#string/storageval"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/expdev"
android:layout_marginTop="305dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/expdev"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="302dp"
android:text="#string/expdeval"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/clear"
android:layout_marginTop="350dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/clear"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="347dp"
android:text="#string/clearval"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/survey"
android:layout_marginTop="395dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/survey"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="392dp"
android:text="#string/surveyval"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/transit"
android:layout_marginTop="440dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/transit"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="438dp"
android:text="#string/transitval"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/total"
android:layout_marginTop="485dp"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/total"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="483dp"
android:text="#string/totval"
android:inputType="text"
android:layout_marginLeft="230dp"
/>
</RelativeLayout>
Please Use below XML code instead of your code, it will solve your problem.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/ttl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="ep"
android:textColor="#00ccff"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:text="eprice"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/ep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="245dp"
android:layout_marginTop="60dp"
android:inputType="text"
android:text="epval" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="molcal"
android:textColor="#00cc00"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="135dp"
android:text="molfac"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/molex"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="122dp"
android:inputType="text"
android:text="molex" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="180dp"
android:text="frght"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/frght"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="167dp"
android:inputType="text"
android:text="frghtport" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="225dp"
android:text="whlfrg"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/whar"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="212dp"
android:inputType="text"
android:text="whlfrgval" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="270dp"
android:text="storage"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/storage"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="257dp"
android:inputType="text"
android:text="storageval" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="305dp"
android:text="expdev"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/expdev"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="302dp"
android:inputType="text"
android:text="expdeval" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="350dp"
android:text="clear"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/clear"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="347dp"
android:inputType="text"
android:text="clearval" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="395dp"
android:text="survey"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/survey"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="392dp"
android:inputType="text"
android:text="surveyval" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="440dp"
android:text="transit"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/transit"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="438dp"
android:inputType="text"
android:text="transitval" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="485dp"
android:text="total"
android:textColor="#BBB000"
android:textSize="14sp"
android:textStyle="bold" />
<EditText
android:id="#+id/total"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="483dp"
android:inputType="text"
android:text="totval" />
</RelativeLayout>
</ScrollView>
Ok it is a good question. You can set the layout height and width to wrap content and if you need to add other things you can use the following tags:
android:layout_below="#+id/textView1"
android:layout_above="#+id/textView1"
android:layout_toRightOf="#+id/textView1"
android:layout_toLeftOf="#+id/textView1"
According to me, Relative Layout is the best to use over others.