Background of RelativeLayout keep jumps and ducks - android

This is what exactly happens, The first screenshot is how it should be but most of the times when I start the activity, it starts like the second screenshot.
It only comes normal after I scroll up and down or focus in/out into some of the fields.
Can someone point out or give a fix to this issue?
Note: the logo is inside #drawable/background which is a jpg file for the whole screen
First:
Second:
Xml Layout Code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sc"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_un"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dip"
android:layout_marginRight="9dip"
android:layout_marginTop="150dip"
android:text="Mobile #:"
android:textColor="#color/newGrey"
android:textSize="13dp" />
<EditText
android:id="#+id/et_un"
android:layout_width="200dip"
android:layout_height="40dp"
android:layout_alignLeft="#+id/tv_un"
android:layout_alignRight="#+id/et_pw"
android:layout_below="#id/tv_un"
android:background="#drawable/username_area"
android:inputType="phone"
android:lines="1"
android:maxLength="11"
android:maxLines="1"
android:singleLine="true"
android:text=""
android:textColor="#color/newGrey" />
<TextView
android:id="#+id/tv_pw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_un"
android:layout_below="#id/et_un"
android:layout_marginRight="9dip"
android:layout_marginTop="15dip"
android:text="Password:"
android:textColor="#color/newGrey"
android:textSize="13dp" />
<EditText
android:id="#+id/et_pw"
android:layout_width="270dip"
android:layout_height="40dp"
android:layout_alignLeft="#+id/tv_pw"
android:layout_below="#id/tv_pw"
android:background="#drawable/username_area"
android:maxLength="30"
android:lines="1"
android:maxLines="1"
android:password="true"
android:singleLine="true"
android:text=""
android:textColor="#color/newGrey" />
<TextView
android:id="#+id/tv_already"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tv_un"
android:layout_alignLeft="#+id/tv_un"
android:layout_marginBottom="41dp"
android:text="Account Login:"
android:textColor="#color/newGrey"
android:textSize="18dp" />
<TextView
android:id="#+id/tv_forgot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_pw"
android:layout_centerHorizontal="true"
android:text="Forgot Password? Click Here"
android:textColor="#color/redish"
android:visibility="invisible" />
<Button
android:id="#+id/btn_LOGIN_in"
android:layout_width="150dp"
android:layout_height="55dp"
android:layout_below="#+id/tv_forgot"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:background="#drawable/button"
android:enabled="false"
android:text="Login"
android:textColor="#color/grey"
android:textSize="20dp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_LOGIN_in"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp"
android:text="Don&apos;t have an account?"
android:textColor="#color/newGrey"
android:textSize="18dp" />
<Button
android:id="#+id/btn_login"
android:layout_width="150dp"
android:layout_height="55dp"
android:layout_alignLeft="#+id/btn_LOGIN_in"
android:layout_below="#+id/textView1"
android:layout_marginTop="31dp"
android:background="#drawable/button"
android:text="Sign up now"
android:textColor="#color/newGrey"
android:textSize="20dp" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="31dp"
android:enabled="false"
android:text="Forgot Password? Click Here"
android:textColor="#color/redish"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>

I have never heard about this before but please try this out.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:background="#drawable/background" >
</View>
<TextView
android:id="#+id/tv_un"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dip"
android:layout_marginRight="9dip"
android:layout_marginTop="150dip"
android:text="Mobile #:"
android:textColor="#color/newGrey"
android:textSize="13dp" />
<EditText
android:id="#+id/et_un"
android:layout_width="200dip"
android:layout_height="40dp"
android:layout_alignLeft="#+id/tv_un"
android:layout_alignRight="#+id/et_pw"
android:layout_below="#id/tv_un"
android:background="#drawable/username_area"
android:inputType="phone"
android:lines="1"
android:maxLength="11"
android:maxLines="1"
android:singleLine="true"
android:text=""
android:textColor="#color/newGrey" />
<TextView
android:id="#+id/tv_pw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_un"
android:layout_below="#id/et_un"
android:layout_marginRight="9dip"
android:layout_marginTop="15dip"
android:text="Password:"
android:textColor="#color/newGrey"
android:textSize="13dp" />
<EditText
android:id="#+id/et_pw"
android:layout_width="270dip"
android:layout_height="40dp"
android:layout_alignLeft="#+id/tv_pw"
android:layout_below="#id/tv_pw"
android:background="#drawable/username_area"
android:maxLength="30"
android:lines="1"
android:maxLines="1"
android:password="true"
android:singleLine="true"
android:text=""
android:textColor="#color/newGrey" />
<TextView
android:id="#+id/tv_already"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tv_un"
android:layout_alignLeft="#+id/tv_un"
android:layout_marginBottom="41dp"
android:text="Account Login:"
android:textColor="#color/newGrey"
android:textSize="18dp" />
<TextView
android:id="#+id/tv_forgot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_pw"
android:layout_centerHorizontal="true"
android:text="Forgot Password? Click Here"
android:textColor="#color/redish"
android:visibility="invisible" />
<Button
android:id="#+id/btn_LOGIN_in"
android:layout_width="150dp"
android:layout_height="55dp"
android:layout_below="#+id/tv_forgot"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:background="#drawable/button"
android:enabled="false"
android:text="Login"
android:textColor="#color/grey"
android:textSize="20dp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_LOGIN_in"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp"
android:text="Don&apos;t have an account?"
android:textColor="#color/newGrey"
android:textSize="18dp" />
<Button
android:id="#+id/btn_login"
android:layout_width="150dp"
android:layout_height="55dp"
android:layout_alignLeft="#+id/btn_LOGIN_in"
android:layout_below="#+id/textView1"
android:layout_marginTop="31dp"
android:background="#drawable/button"
android:text="Sign up now"
android:textColor="#color/newGrey"
android:textSize="20dp" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="31dp"
android:enabled="false"
android:text="Forgot Password? Click Here"
android:textColor="#color/redish"
android:visibility="invisible" />
</RelativeLayout>
Or you could try this.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sc"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tv_un"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dip"
android:layout_marginRight="9dip"
android:layout_marginTop="150dip"
android:text="Mobile #:"
android:textColor="#color/newGrey"
android:textSize="13dp" />
<EditText
android:id="#+id/et_un"
android:layout_width="200dip"
android:layout_height="40dp"
android:layout_alignLeft="#+id/tv_un"
android:layout_alignRight="#+id/et_pw"
android:layout_below="#id/tv_un"
android:background="#drawable/username_area"
android:inputType="phone"
android:lines="1"
android:maxLength="11"
android:maxLines="1"
android:singleLine="true"
android:text=""
android:textColor="#color/newGrey" />
<TextView
android:id="#+id/tv_pw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_un"
android:layout_below="#id/et_un"
android:layout_marginRight="9dip"
android:layout_marginTop="15dip"
android:text="Password:"
android:textColor="#color/newGrey"
android:textSize="13dp" />
<EditText
android:id="#+id/et_pw"
android:layout_width="270dip"
android:layout_height="40dp"
android:layout_alignLeft="#+id/tv_pw"
android:layout_below="#id/tv_pw"
android:background="#drawable/username_area"
android:lines="1"
android:maxLength="30"
android:maxLines="1"
android:password="true"
android:singleLine="true"
android:text=""
android:textColor="#color/newGrey" />
<TextView
android:id="#+id/tv_already"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tv_un"
android:layout_alignLeft="#+id/tv_un"
android:layout_marginBottom="41dp"
android:text="Account Login:"
android:textColor="#color/newGrey"
android:textSize="18dp" />
<TextView
android:id="#+id/tv_forgot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_pw"
android:layout_centerHorizontal="true"
android:text="Forgot Password? Click Here"
android:textColor="#color/redish"
android:visibility="invisible" />
<Button
android:id="#+id/btn_LOGIN_in"
android:layout_width="150dp"
android:layout_height="55dp"
android:layout_below="#+id/tv_forgot"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:background="#drawable/button"
android:enabled="false"
android:text="Login"
android:textColor="#color/grey"
android:textSize="20dp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_LOGIN_in"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp"
android:text="Don&apos;t have an account?"
android:textColor="#color/newGrey"
android:textSize="18dp" />
<Button
android:id="#+id/btn_login"
android:layout_width="150dp"
android:layout_height="55dp"
android:layout_alignLeft="#+id/btn_LOGIN_in"
android:layout_below="#+id/textView1"
android:layout_marginTop="31dp"
android:background="#drawable/button"
android:text="Sign up now"
android:textColor="#color/newGrey"
android:textSize="20dp" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="31dp"
android:enabled="false"
android:text="Forgot Password? Click Here"
android:textColor="#color/redish"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

Related

scrollview not starting at the top of the activity

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>

Android app freezes after scrolling a little

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>

Please help my ListView stop vertical scrolling

I've created a ListView in a nested LinearLayouts with Horizontal scrolling in an attempt to display long records with the capability for Horizontal scrolling, but now I'm unable to scroll the ListView vertically.
Here is my XML setup. Can you help me figure out why the ListView stop scrolling. I've found several article tried difference Width, Height and Weight layout, but nothing seems to work.
Thank you in advance for your help.
<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"
tools:context=".ProductReview" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="40sp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:contentDescription="#string/lyellow_strip"
android:scaleType="centerCrop"
android:src="#drawable/shell_strip" />
<ImageView
android:id="#+id/imgVCancel"
android:layout_width="27sp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView2"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="224dp"
android:clickable="true"
android:contentDescription="#string/btnCancel"
android:onClick="Cancel"
android:src="#drawable/cancel32" />
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/imageView2" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="527dp"
android:orientation="horizontal" >
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginLeft="40dp"
android:orientation = "horizontal">
<TextView
android:id="#+id/code"
android:layout_width="110sp"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="Type"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/manufacturer"
android:layout_width="70sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/code"
android:maxLines="1"
android:text="Manu"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/name"
android:layout_width="300sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/manufacturer"
android:maxLines="1"
android:text="Product Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/visc40"
android:layout_width="80sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/name"
android:maxLines="1"
android:text="Visc 40"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/visc100"
android:layout_width="80sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/visc40"
android:maxLines="1"
android:text="Visc 100"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/viscindex"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/visc100"
android:maxLines="1"
android:text="Visc Index"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/den15c"
android:layout_width="80sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/viscindex"
android:maxLines="1"
android:text="Den#15c"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/name1"
android:layout_width="300sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/den15c"
android:maxLines="1"
android:text="Product Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/visctext"
android:layout_width="150sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/name1"
android:maxLines="1"
android:text="Visc Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/baseoiltype"
android:layout_width="150sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/visctext"
android:maxLines="1"
android:text="Base Oil Type"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/name2"
android:layout_width="300sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/baseoiltype"
android:maxLines="1"
android:text="Product Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/baseoil"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/name2"
android:maxLines="1"
android:text="Base Oil"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/additives"
android:layout_width="300sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/baseoil"
android:maxLines="1"
android:text="Additives"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/name3"
android:layout_width="300sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/additives"
android:maxLines="1"
android:text="Product Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/otheradditives"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/name3"
android:maxLines="1"
android:text="Other Properties"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/thickener"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/otheradditives"
android:maxLines="1"
android:text="Thickener"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/nlgi"
android:layout_width="70sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/thickener"
android:maxLines="1"
android:text="NLGI"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/name4"
android:layout_width="300sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/nlgi"
android:maxLines="1"
android:text="Product Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/comments"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/name4"
android:maxLines="1"
android:text="Comments"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/packages"
android:layout_width="300sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/comments"
android:maxLines="1"
android:text="Packages"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/area"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/packages"
android:maxLines="1"
android:text="Areas"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/usage"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="11dp"
android:layout_toRightOf="#+id/area"
android:maxLines="1"
android:text="Usage"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginLeft="-4060dp"
android:layout_marginTop="30dp"
android:orientation = "horizontal">
<ListView
android:id="#+id/listView1"
android:layout_width="0dip"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:fastScrollEnabled="true"
android:headerDividersEnabled="true"
android:smoothScrollbar="true" >
</ListView>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
I've figured out what to do. This is probably not the best way, but it work for us. I put the column headers one linear layout and the ListView in another. Thanks.

how to make a relative layout scrollable when it has many children views?

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>

How to do Android layout wrap with contents?

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.

Categories

Resources