How to do Android layout wrap with contents? - android

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.

Related

Android is it possible to have a part of the layout scrollable

I am trying to make an android application and I need the middle part of my screen to be scrollable. When I set a ScrollView inside an Relative Layout my application crashes.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backgroundcolor"
android:orientation="vertical">
<TextView
android:id="#+id/tvCijferHalen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView"
android:layout_alignParentEnd="true"
android:layout_alignStart="#+id/etWegingTehalenCijfer"
android:layout_alignTop="#+id/textView"
android:layout_marginEnd="26dp"
android:layout_marginStart="20dp"
android:background="?android:attr/colorPressedHighlight"
android:paddingStart="65dp"
android:paddingTop="15dp"
android:text="0"
android:textColor="?attr/editTextColor"
android:textSize="30dp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/etWatStaan"
android:layout_alignEnd="#+id/etWatStaan"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="328dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:background="#android:color/holo_green_light"
android:paddingStart="65dp"
android:paddingTop="15dp"
android:text="0"
android:textColor="?attr/editTextColor"
android:textSize="30dp" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/tvCijferHalen"
android:layout_above="#+id/etWatStaan"
android:layout_alignStart="#+id/textView"
android:layout_alignEnd="#+id/tvCijferHalen">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativelayout"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:background="#color/backgroundcolor"
android:orientation="vertical">
<EditText
android:id="#+id/etcijfer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="185dp"
android:layout_marginTop="46dp"
android:ems="10"
android:hint="Cijfer 1"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="visible" />
<EditText
android:id="#+id/etweging1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/etcijfer1"
android:layout_alignBottom="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_marginEnd="28dp"
android:layout_marginRight="46dp"
android:layout_marginStart="187dp"
android:layout_toStartOf="#+id/bLess1"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="visible" />
<Button
android:id="#+id/bLess1"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging1"
android:layout_alignParentEnd="true" />
<EditText
android:id="#+id/etcijfer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer1"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 2"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging1"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess2"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess2"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging2"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer2"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 3"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging2"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess2"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess3"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging3"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer3"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 4"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging3"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess3"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess4"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging4"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer4"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 5"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging4"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess4"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess5"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging5"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer5"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 6"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging5"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess5"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess6"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging6"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer6"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 7"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging6"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess6"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess7"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging7"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
</RelativeLayout>
</ScrollView>
<EditText
android:id="#+id/etWatStaan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/bNiewCijfer"
android:layout_alignEnd="#+id/etWegingTehalenCijfer"
android:layout_alignParentStart="true"
android:layout_marginEnd="200dp"
android:layout_marginRight="48dp"
android:ems="10"
android:hint="Wat wil je staan"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray" />
<EditText
android:id="#+id/etWegingTehalenCijfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:ems="10"
android:hint="weging"
android:inputType="number"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:layout_alignBaseline="#+id/etWatStaan"
android:layout_alignBottom="#+id/etWatStaan"
android:layout_alignParentStart="true"
android:layout_marginStart="187dp" />
<Button
android:id="#+id/bNiewCijfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="Cijfer Toevoegen"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView7"
android:layout_alignBottom="#+id/textView7"
android:layout_alignEnd="#+id/tvCijferHalen"
android:layout_alignStart="#+id/tvCijferHalen"
android:background="?android:attr/colorMultiSelectHighlight"
android:text="Te halen Cijfer"
android:textAlignment="center"
android:textColor="?attr/editTextColor" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/textView"
android:layout_marginTop="13dp"
android:background="#android:color/holo_green_dark"
android:text="Gemiddelde"
android:textAlignment="center"
android:textColor="?attr/editTextColor" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignEnd="#+id/ScrollView01"
android:layout_alignStart="#+id/tvCijferHalen"
android:layout_marginEnd="71dp"
android:text="Weging"
android:textAlignment="center"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView"
android:layout_alignStart="#+id/ScrollView01"
android:layout_alignTop="#+id/ScrollView01"
android:layout_marginTop="31dp"
android:text="Cijfer"
android:textAlignment="center"
android:textColor="#android:color/black" />
Can someone help me ? I am wondering if it's even possible to have only a part of the screen scrollable
Try this approach:
Step 1
Use a LinearLayout as your root element to enable you to use layout_weightattribute;
Step 2
Inside your layout, you can split it into 3 parts each with a layout_weight of .3
For example:
<LinearLayout
...
orientation="vertical"
... >
<LinearLayout
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
<ScrollView
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
<LinearLayout
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
</LinearLayout> !-- end of root layout here
I said .3 just in case you want to have the sections occupy the same size of the window; but you can set them to whatever you want according to your needs.
I hope this helps.
Note A ScrollView only accepts ONE child element!
Good luck!

Android SDK: RelativeLayout - Button WILL NOT center horizontally, even with Layout_CenterHorizontal=true

I really hope somebody can help me here because I am going to start pulling my hair out if this keeps doing what it's doing.
I'm trying to design a layout and I want all of my stuff to be centered. So far, everything is. However, the Save button I created will not center itself for the life of it. It consistently aligns its left edge with the center of the screen, rather than the center of the button itself.
Below is a screenshot of my simple design and the xml behind it... Any help will be GREATLY appreciated!
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_settings"
tools:context="com.hypertom.weeklymealgenerator.SettingsActivity"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/strSettingsTitle"
android:id="#+id/textView"
android:textIsSelectable="false"
android:textSize="30sp"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/textView2" />
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/strSettingsNumMeals"
android:id="#+id/textView2"
android:layout_below="#+id/textView"
android:layout_alignParentStart="true"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"
android:gravity="right"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/strSettingsThresholdMin"
android:id="#+id/textView3"
android:layout_below="#+id/textView2"
android:layout_alignEnd="#+id/textView2"
android:layout_marginTop="10dp"
android:gravity="right"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/strSettingsThresholdMax"
android:id="#+id/textView4"
android:layout_below="#+id/textView3"
android:layout_alignEnd="#+id/textView3"
android:layout_marginTop="10dp"
android:gravity="right"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/strSettingsNumServings"
android:id="#+id/textView5"
android:layout_below="#+id/textView4"
android:layout_alignEnd="#+id/textView4"
android:layout_marginTop="10dp"
android:gravity="right"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/strSettingsNumSubstitutes"
android:id="#+id/textView6"
android:layout_below="#+id/textView5"
android:layout_alignEnd="#+id/textView5"
android:layout_marginTop="10dp"
android:gravity="right"
android:textSize="18sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btnSettingsSave"
android:id="#+id/button4"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="200dp" />
<EditText
android:layout_width="65dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText"
android:layout_alignBottom="#+id/textView2"
android:layout_toEndOf="#+id/textView2"
android:layout_marginBottom="-12dp"
android:textSize="18sp"
android:gravity="center" />
<EditText
android:layout_width="65dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText2"
android:layout_alignBottom="#+id/textView3"
android:layout_alignStart="#+id/editText"
android:textSize="18sp"
android:layout_marginBottom="-12dp"
android:gravity="center" />
<EditText
android:layout_width="65dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText3"
android:layout_above="#+id/textView5"
android:layout_alignStart="#+id/editText2"
android:layout_marginBottom="-12dp"
android:textSize="18sp"
android:gravity="center" />
<EditText
android:layout_width="65dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText4"
android:layout_above="#+id/textView6"
android:layout_alignStart="#+id/editText3"
android:textSize="18sp"
android:layout_marginBottom="-12dp"
android:gravity="center" />
<EditText
android:layout_width="65dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText5"
android:layout_alignBottom="#+id/textView6"
android:layout_alignStart="#+id/editText4"
android:layout_marginBottom="-12dp"
android:textSize="18sp"
android:gravity="center" />
</RelativeLayout>
Something like this ? It can be done much easier in LinearLayout though.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:text="strSettingsTitle"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textIsSelectable="false"
android:textSize="30sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:id="#+id/linearlayout">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="10dp"
android:layout_centerInParent="true">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="# of Meals"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_below="#+id/textView2"
android:layout_marginTop="10dp"
android:gravity="right"
android:text="Threshold Min"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_below="#+id/textView3"
android:layout_marginTop="10dp"
android:gravity="right"
android:text="Threshold Max"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_below="#+id/textView4"
android:gravity="right"
android:layout_marginTop="10dp"
android:text="Num of Servings"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="30dp"
android:layout_below="#+id/textView5"
android:layout_marginTop="10dp"
android:text="Num of Substitutes"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="10dp">
<EditText
android:id="#+id/editText"
android:layout_width="65dp"
android:layout_height="30dp"
android:ems="10"
android:inputType="number"
android:textSize="18sp" />
<EditText
android:id="#+id/editText2"
android:layout_width="65dp"
android:layout_height="30dp"
android:layout_marginTop="10dp"
android:layout_below="#+id/editText"
android:ems="10"
android:inputType="number"
android:textSize="18sp" />
<EditText
android:id="#+id/editText3"
android:layout_width="65dp"
android:layout_height="30dp"
android:layout_below="#+id/editText2"
android:layout_marginTop="10dp"
android:ems="10"
android:inputType="number"
android:textSize="18sp" />
<EditText
android:id="#+id/editText4"
android:layout_width="65dp"
android:layout_height="30dp"
android:layout_below="#+id/editText3"
android:layout_marginTop="10dp"
android:ems="10"
android:inputType="number"
android:textSize="18sp" />
<EditText
android:id="#+id/editText5"
android:layout_width="65dp"
android:layout_height="30dp"
android:layout_below="#+id/editText4"
android:layout_marginTop="10dp"
android:ems="10"
android:inputType="number"
android:textSize="18sp" />
</RelativeLayout>
</LinearLayout>
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_centerInParent="true"
android:layout_below="#+id/linearlayout"
android:text="Save" />
</RelativeLayout>

How to use scroll view in relative layout which exist in fragment?

i am stuck how to scroll layout when keyboard appear? this is my static page but when my keyboard appear then my scrollview is not working.i can not give hard code height of scrollview. please help me..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/settingLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/splash_bg" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/tree_iv_userSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/tree_transparent" />
<ImageView
android:id="#+id/image1"
android:layout_width="90dp"
android:layout_height="110dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:src="#drawable/frame_large" />
<TextView
android:id="#+id/changepassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/image1"
android:layout_marginLeft="20dp"
android:background="#android:color/transparent"
android:hint="CHANGE PASSWORD"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black" />
<EditText
android:id="#+id/editname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/changepassword"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:hint="EDIT NAME"
android:maxLength="20"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColorHint="#android:color/black" />
<EditText
android:id="#+id/editphoneno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editname"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:hint="EDIT PHONE NUMBER"
android:maxLength="15"
android:numeric="integer"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColorHint="#android:color/black" />
<TextView
android:id="#+id/edittype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editphoneno"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:singleLine="true"
android:text="EDIT TYPE"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/edittype"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:singleLine="true"
android:text="NOTIFICATION"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black" />
<Button
android:id="#+id/togNot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/save"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="#drawable/on_button" />
<TextView
android:id="#+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/notification"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:text="SAVE "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black"
android:textSize="40dp" />
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/image1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="27dp" />
</RelativeLayout>
</ScrollView>
Please help me out.
suggestions apreciated
Thanks Kind Regards.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/splash_bg" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/tree_iv_userSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/tree_transparent" />
<ImageView
android:id="#+id/image1"
android:layout_width="90dp"
android:layout_height="110dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:src="#drawable/frame_large" />
<TextView
android:id="#+id/changepassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/image1"
android:layout_marginLeft="20dp"
android:background="#android:color/transparent"
android:hint="CHANGE PASSWORD"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black" />
<EditText
android:id="#+id/editname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/changepassword"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:hint="EDIT NAME"
android:maxLength="20"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColorHint="#android:color/black" />
<EditText
android:id="#+id/editphoneno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editname"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:hint="EDIT PHONE NUMBER"
android:maxLength="15"
android:numeric="integer"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColorHint="#android:color/black" />
<TextView
android:id="#+id/edittype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editphoneno"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:singleLine="true"
android:text="EDIT TYPE"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/edittype"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:singleLine="true"
android:text="NOTIFICATION"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black" />
<Button
android:id="#+id/togNot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/save"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="#drawable/on_button" />
<TextView
android:id="#+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/notification"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:text="SAVE "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black"
android:textSize="40dp" />
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/image1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="27dp" />
</RelativeLayout>
And add this code to ypur manifest project:
<activity
android:name="YourActivity"
android:windowSoftInputMode="stateVisible|stateAlwaysVisible" >
</activity>
add this code in ur manifest activty
android:windowSoftInputMode="adjustPan|stateAlwaysVisible"
this code useful for scrolling relative layout..
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="#+id/settingLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/splash_bg" >
<ImageView
android:id="#+id/tree_iv_userSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/tree_transparent" />
<ImageView
android:id="#+id/image1"
android:layout_width="90dp"
android:layout_height="110dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:src="#drawable/frame_large" />
<TextView
android:id="#+id/changepassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/image1"
android:layout_marginLeft="20dp"
android:background="#android:color/transparent"
android:hint="CHANGE PASSWORD"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black" />
<EditText
android:id="#+id/editname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/changepassword"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:hint="EDIT NAME"
android:maxLength="20"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColorHint="#android:color/black" />
<EditText
android:id="#+id/editphoneno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editname"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:hint="EDIT PHONE NUMBER"
android:maxLength="15"
android:numeric="integer"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColorHint="#android:color/black" />
<TextView
android:id="#+id/edittype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editphoneno"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:singleLine="true"
android:text="EDIT TYPE"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/edittype"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
android:singleLine="true"
android:text="NOTIFICATION"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black" />
<Button
android:id="#+id/togNot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/save"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="#drawable/on_button" />
<TextView
android:id="#+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/notification"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:text="SAVE "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/black"
android:textSize="40dp" />
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/image1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="27dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bottomRelay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="7.5dp"
android:background="#android:color/transparent"
android:visibility="gone" >
<TextView
android:id="#+id/Upload"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#ededed"
android:gravity="center"
android:text="Upload Photo"
android:textColor="#8F8F8F"
android:textSize="20dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/border1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/Upload"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#939393" />
<TextView
android:id="#+id/choose_existing"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/border1"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="1dp"
android:background="#ededed"
android:gravity="center"
android:text="Library"
android:textColor="#007AFF"
android:textSize="20dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/border2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/choose_existing"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#939393" />
<TextView
android:id="#+id/Camera"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/border2"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="1dp"
android:background="#ededed"
android:gravity="center"
android:text="Camera"
android:textColor="#007AFF"
android:textSize="20dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/border3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/Camera"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#939393" />
<TextView
android:id="#+id/cancel"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/border3"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:background="#ededed"
android:gravity="center"
android:text="Cancel"
android:textColor="#007AFF"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>

How to correct Android Activity's Layout elements stacking over each other?

I have a problem in the layout of my app's activity. The top elements (text-views, edit text boxes) are coming jumbled up.
There is some sort of overlapping between elements though XML Layout's code looks fine (a similarly designed code is in use by another activity and is working fine).Here is a ScreenShot (notice the overlapping of elements near top):
My XML Layout's code:(for reference)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/my_main_border"
android:fillViewport="true" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:context=".Ques1" >
<TextView
android:id="#+id/textView_outlet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dp"
android:layout_marginTop="26dp"
android:text="#string/name_outlet"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_outlet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignBaseline="#id/textView_outlet"
android:layout_toRightOf="#id/textView_outlet"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,&apos;1234567890 "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_outlet"
android:background="#android:color/darker_gray"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<TextView
android:id="#+id/textView1_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view1"
android:text="#string/name_owner"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/textView1_owner"
android:layout_toRightOf="#id/textView1_owner"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.&apos; "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_owner"
android:background="#android:color/darker_gray"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<TextView
android:id="#+id/textView1_phonenos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view2"
android:text="#string/phone_nos"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_phonenos"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/textView1_phonenos"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="3"
android:textSize="12sp" />
<EditText
android:id="#+id/editText1_phonenos2"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/editText1_phonenos"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="4"
android:textSize="12sp" />
<EditText
android:id="#+id/editText1_phonenos3"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/editText1_phonenos2"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="5"
android:textSize="12sp" />
<EditText
android:id="#+id/editText1_phonenos4"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/editText1_phonenos3"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="5"
android:textSize="12sp" />
<View
android:id="#+id/view3"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_phonenos4"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view3"
android:text="#string/name_state"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/textView1_state"
android:layout_toRightOf="#id/textView1_state"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.&apos; "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view4"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_state"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view4"
android:text="#string/name_city"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/textView1_city"
android:layout_toRightOf="#id/textView1_city"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view5"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_city"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_market"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view5"
android:text="#string/market"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_market"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/textView1_market"
android:layout_toRightOf="#id/textView1_market"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,&apos;1234567890 "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view6"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_market"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_gps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view6"
android:text="#string/gps_coord"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_gps"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignBaseline="#id/textView1_gps"
android:layout_toRightOf="#id/textView1_gps"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view7"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_gps"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_outlet_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view7"
android:text="#string/pic_outlet"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/Button01_outletpic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/textView1_outlet_pic"
android:drawableLeft="#drawable/select_pic"
android:text="#string/selectPic_btn"
android:textSize="10sp" />
<View
android:id="#+id/view8"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/Button01_outletpic"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_quad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view8"
android:text="#string/quad_code"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_quad"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignBaseline="#id/textView1_quad"
android:layout_toRightOf="#id/textView1_quad"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view9"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_quad"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_own_veh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view9"
android:text="#string/own_veh"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radioGroup1_own_veh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1_own_veh"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/radio0_yes"
android:textSize="13sp" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/radio0"
android:text="#string/radio1_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="#+id/view10"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/radioGroup1_own_veh"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_own_sales_team"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view10"
android:text="#string/own_sales_team"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radioGroup1_own_salesT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1_own_sales_team"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio011"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/radio011_yes"
android:textSize="13sp" />
<RadioButton
android:id="#+id/radio022"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/radio011"
android:text="#string/radio022_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="#+id/view11"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/radioGroup1_own_salesT"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_own_goods_collect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view11"
android:text="#string/own_goods_collect"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radioGroup1_own_goods_coll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1_own_goods_collect"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio033"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/radio033_yes"
android:textSize="13sp" />
<RadioButton
android:id="#+id/radio044"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/radio033"
android:text="#string/radio044_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="#+id/view12"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/radioGroup1_own_goods_coll"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_monthly_vOl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view12"
android:text="#string/monthly_vOl"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="#+id/cbCat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1_monthly_vOl"
android:layout_marginLeft="50dp"
android:text="#string/cat1"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat1"
android:layout_marginLeft="55dp"
android:layout_toRightOf="#id/cbCat1"
android:text="#string/cat2"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat1"
android:layout_marginLeft="50dp"
android:text="#string/cat3"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat3"
android:layout_marginLeft="9dp"
android:layout_toRightOf="#id/cbCat3"
android:text="#string/cat4"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat3"
android:layout_marginLeft="50dp"
android:text="#string/cat5"
android:textSize="13sp" />
<View
android:id="#+id/view13"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/cbCat5"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_monthly_vAl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view13"
android:text="#string/monthly_vAl"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="#+id/cbCat11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1_monthly_vAl"
android:layout_marginLeft="50dp"
android:text="#string/cat11"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat11"
android:layout_marginLeft="8dp"
android:layout_toRightOf="#id/cbCat11"
android:text="#string/cat22"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat11"
android:layout_marginLeft="50dp"
android:text="#string/cat33"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat33"
android:layout_marginLeft="9dp"
android:layout_toRightOf="#id/cbCat33"
android:text="#string/cat44"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat33"
android:layout_marginLeft="50dp"
android:text="#string/cat55"
android:textSize="13sp" />
<View
android:id="#+id/view14"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/cbCat55"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<View
android:id="#+id/viewMenuBarP1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/view14"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<Button
android:id="#+id/btnNxtPage2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/viewMenuBarP1"
android:layout_centerInParent="true"
android:gravity="center"
android:text="#string/btnNextPage2" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Any advice is appreciable..Thanks in advance
Don't define toRightOf only, but toLeftOf, above and below too when needed.
Use android:layout_alignBaseline="#id/textView_outlet" and not android:layout_alignBaseline="#+id/textView_outlet"
#+id is to create a new id whereas #id is used when the id has already been created.
Please feel free to ask any doubts if the problem persists
Try this code :
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:fillViewport="true" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
app:context=".Ques1" >
<TextView
android:id="#+id/textView_outlet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="name_outlet"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_outlet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/textView_outlet"
android:layout_alignParentRight="true"
android:layout_toRightOf="#id/textView_outlet"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,&apos;1234567890 "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/editText1_outlet"
android:background="#android:color/darker_gray"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<TextView
android:id="#+id/textView1_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view1"
android:text="name_owner"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/textView1_owner"
android:layout_alignParentRight="true"
android:layout_toRightOf="#id/textView1_owner"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.&apos; "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/textView1_owner"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<View
android:id="#+id/view3"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/editText1_phonenos4"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view3"
android:text="name_state"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1_state"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/textView1_state"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.&apos; "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view4"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1_state"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<TextView
android:id="#+id/textView1_phonenos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/view2"
android:text="phone_nos"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_phonenos"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1_phonenos"
android:layout_alignBottom="#+id/textView1_phonenos"
android:layout_marginLeft="14dp"
android:layout_toRightOf="#+id/textView1_phonenos"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="3"
android:textSize="12sp" />
<EditText
android:id="#+id/editText1_phonenos2"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText1_phonenos"
android:layout_alignBottom="#+id/editText1_phonenos"
android:layout_toRightOf="#+id/editText1_phonenos"
android:ems="3"
android:inputType="phone"
android:maxLength="5"
android:textSize="12sp" />
<EditText
android:id="#+id/editText1_phonenos3"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/textView1_phonenos"
android:layout_toRightOf="#+id/editText1_phonenos2"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="5"
android:textSize="12sp" />
<EditText
android:id="#+id/editText1_phonenos4
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText1_phonenos3"
android:layout_alignBottom="#+id/editText1_phonenos3"
android:layout_toRightOf="#+id/editText1_phonenos3"
android:digits="0123456789"
android:ems="3"
android:inputType="phone"
android:maxLength="5"
android:textSize="12sp" />
<TextView
android:id="#+id/textView1_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view4"
android:text="name_city"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1_city"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/textView1_city"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view5"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/textView1_city"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_market"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view5"
android:text="market"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_market"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1_market"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/textView1_market"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,&apos;1234567890 "
android:ems="10"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view6"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/textView1_market"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_gps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view6"
android:text="gps_coord"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1_gps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1_gps"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/textView1_gps"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view7"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/textView1_gps"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_outlet_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view7"
android:text="pic_outlet"
android:textAppearance="?android:attr/textAppearanceMedium" />
<View
android:id="#+id/view8"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/textView1_outlet_pic"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_quad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view8"
android:text="quad_code"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/Button01_outletpic"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignTop="#+id/textView1_outlet_pic"
android:layout_toRightOf="#+id/textView1_state"
android:drawableLeft="#drawable/select_pic"
android:text="selectPic_btn"
android:textSize="10sp" />
<EditText
android:id="#+id/editText1_quad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1_quad"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/textView1_quad"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="textPersonName"
android:textSize="12sp" />
<View
android:id="#+id/view9"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1_quad"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"/>
android:paddingTop="2dp"
<TextView
android:id="#+id/textView1_own_veh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view9"
android:text="own_veh"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radioGroup1_own_veh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1_own_veh"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="radio0_yes"
android:textSize="13sp" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/radio0"
android:text="radio1_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="#+id/view10"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/radioGroup1_own_veh"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_own_sales_team"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view10"
android:text="own_sales_team"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radioGroup1_own_salesT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1_own_sales_team"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio011"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="radio011_yes"
android:textSize="13sp" />
<RadioButton
android:id="#+id/radio022"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/radio011"
android:text="radio022_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="#+id/view11"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/radioGroup1_own_salesT"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_own_goods_collect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view11"
android:text="own_goods_collect"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radioGroup1_own_goods_coll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1_own_goods_collect"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio033"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="radio033_yes"
android:textSize="13sp" />
<RadioButton
android:id="#+id/radio044"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/radio033"
android:text="radio044_no"
android:textSize="13sp" />
</RadioGroup>
<View
android:id="#+id/view12"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/radioGroup1_own_goods_coll"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_monthly_vOl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view12"
android:text="#string/monthly_vOl"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="#+id/cbCat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1_monthly_vOl"
android:layout_marginLeft="50dp"
android:text="#string/cat1"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat1"
android:layout_marginLeft="55dp"
android:layout_toRightOf="#id/cbCat1"
android:text="#string/cat2"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat1"
android:layout_marginLeft="50dp"
android:text="#string/cat3"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat3"
android:layout_marginLeft="9dp"
android:layout_toRightOf="#id/cbCat3"
android:text="#string/cat4"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat3"
android:layout_marginLeft="50dp"
android:text="#string/cat5"
android:textSize="13sp" />
The code continue to be here:
<View
android:id="#+id/view13"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/cbCat5"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<TextView
android:id="#+id/textView1_monthly_vAl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/view13"
android:text="#string/monthly_vAl"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="#+id/cbCat11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1_monthly_vAl"
android:layout_marginLeft="50dp"
android:text="#string/cat11"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat11"
android:layout_marginLeft="8dp"
android:layout_toRightOf="#id/cbCat11"
android:text="#string/cat22"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat11"
android:layout_marginLeft="50dp"
android:text="#string/cat33"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/cbCat33"
android:layout_marginLeft="9dp"
android:layout_toRightOf="#id/cbCat33"
android:text="#string/cat44"
android:textSize="13sp" />
<CheckBox
android:id="#+id/cbCat55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cbCat33"
android:layout_marginLeft="50dp"
android:text="#string/cat55"
android:textSize="13sp" />
<View
android:id="#+id/view14"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/cbCat55"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<View
android:id="#+id/viewMenuBarP1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#id/view14"
android:background="#android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
<Button
android:id="#+id/btnNxtPage2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/viewMenuBarP1"
android:layout_centerInParent="true"
android:gravity="center"
android:text="#string/btnNextPage2" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

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>

Categories

Resources