0

I am Trying to show four Textview And Four EditText on a scroll view , when I am using scrollview then only show last TextView and edit text.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
android:paddingLeft="20dip"
android:paddingTop="10dip"
android:paddingRight="20dip"
android:orientation="vertical"

 >
<ScrollView 
    android:layout_height="0px"
    android:layout_width="fill_parent"

    android:paddingTop="5dip"
     android:layout_weight="1"

   >
   <RelativeLayout android:layout_height="wrap_content"
       android:layout_width="match_parent"
      >
    <TextView 
        android:id="@+id/txtlocation"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6dip"

        android:text="Location"/>

    <EditText
        android:id="@+id/location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtlocation"
         android:background="@android:drawable/editbox_background"
         android:singleLine="true"
         android:ems="10" >

        <requestFocus android:layout_width="match_parent" />

    </EditText>




    <TextView 
        android:id="@+id/txtminimum"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6.5dip"

        android:text="Minimum Price*"/>

    <AutoCompleteTextView
        android:id="@+id/autominimum"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtminimum"
        android:background="@android:drawable/editbox_background"
        android:ems="10"
        android:singleLine="true" >

        <requestFocus android:layout_width="wrap_content" />

    </AutoCompleteTextView>

   <ImageView
    android:id="@+id/imgminimum"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/autominimum"
    android:layout_alignRight="@+id/autominimum"
    android:layout_alignTop="@+id/autominimum"

    android:src="@drawable/dropdown" />



    <TextView 
        android:id="@+id/txtmaximum"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6dip"

        android:text="Maximum Price*"/>

    <AutoCompleteTextView
        android:id="@+id/automaximum"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtmaximum"
         android:background="@android:drawable/editbox_background"
         android:singleLine="true"
         android:ems="10" >

        <requestFocus />
    </AutoCompleteTextView>

   <ImageView
    android:id="@+id/imgmaximum"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/automaximum"
    android:layout_alignRight="@+id/automaximum"
    android:layout_alignTop="@+id/automaximum"
    android:src="@drawable/dropdown" />


    <TextView 
        android:id="@+id/txtproperty"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6dip"

        android:text="Property Type*"/>

    <AutoCompleteTextView
        android:id="@+id/autoproperty"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtproperty"
         android:background="@android:drawable/editbox_background"
         android:singleLine="true"
         android:ems="10" >

        <requestFocus />
    </AutoCompleteTextView>

   <ImageView
    android:id="@+id/imgproperty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/autoproperty"
    android:layout_alignRight="@+id/autoproperty"
    android:layout_alignTop="@+id/autoproperty"
    android:src="@drawable/dropdown" />
  </RelativeLayout>

 </ScrollView>
  <Button
      android:layout_marginTop="20dip"
      android:id="@+id/btnsearch"
      android:layout_width="100dip"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal"
      android:background="@drawable/rounded"
      android:textColor="#FFFFFF"
      android:textSize="18sp"
      android:text="Search" />




      <TextView 
          android:layout_margin="5dip"
           android:id="@+id/txtsigninor"
          android:layout_height="wrap_content"
          android:layout_width="fill_parent"
          android:gravity="center_horizontal"
          android:layout_below="@+id/btnParent"
          android:text="Bfyevfhevf"/>



  <LinearLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_marginBottom="5dip"
  android:gravity="center"
   android:orientation="horizontal"
   android:weightSum="10"
  android:id="@+id/btnParent" >

   <Button
    android:isScrollContainer="false"
    android:id="@+id/btn_Login1"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:layout_marginBottom="5dp"
   android:background="@drawable/rounded"
    android:gravity="center"
    android:textColor="#FFFFFF"
      android:textSize="18sp"
    android:text="  Login  " />

  <Button
    android:isScrollContainer="false"
    android:id="@+id/btn_register"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:layout_marginBottom="5dp"
    android:background="@drawable/rounded"
    android:gravity="center"
    android:text=" Register " 
    android:textColor="#FFFFFF"
      android:textSize="18sp"
    />

  </LinearLayout>
  </LinearLayout>

Output enter image description here Expected

I want to set scrollview In a frist four Text and EditBox. Please suggest me How I can fix this Issue

Thanks In Advance

Any Help Is Appreciated

Kuldeep
  • 367
  • 2
  • 7
  • 19

3 Answers3

1

Use this one for Displaying whole layout using scrollbar.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#d3d3d3">
<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 

    >


     <EditText
            android:id="@+id/edtname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="16dp"
            android:ems="10"
            android:hint="Enter Name*" />

     <TextView
         android:id="@+id/tv1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignBaseline="@+id/edtname"
         android:layout_alignBottom="@+id/edtname"
         android:layout_alignParentLeft="true"
         android:text="Payee" />

 <EditText
     android:id="@+id/edtamount"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignBaseline="@+id/tv3"
     android:layout_alignBottom="@+id/tv3"
     android:layout_alignLeft="@+id/spcategory"
     android:ems="10"
     android:hint="1.00"
     android:inputType="number" />

        <EditText
            android:id="@+id/edtduedate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/edtamount"
            android:layout_below="@+id/edtamount"
            android:layout_marginTop="25dp"
            android:ems="10" >

            <requestFocus />
        </EditText>


         <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/spayfrom"
            android:layout_marginTop="18dp"
            android:text="Notes" />

        <EditText
            android:id="@+id/edtnotes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/textView1"
            android:layout_alignBottom="@+id/textView1"
            android:layout_alignLeft="@+id/spayfrom"
            android:ems="10" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignTop="@+id/radioGroup1"
            android:layout_marginTop="15dp"
            android:text="Repeat" />

        <Spinner
            android:id="@+id/spiner_reapeat"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_alignLeft="@+id/radioGroup1"
            android:layout_below="@+id/radioGroup1" />

        <RadioGroup
            android:id="@+id/radioGroup1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/edtnotes"
            android:layout_below="@+id/edtnotes"
            android:layout_marginTop="14dp"
            android:orientation="horizontal" >

            <RadioButton
                android:id="@+id/radio0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="Yes" />

            <RadioButton
                android:id="@+id/radio1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="No" />
        </RadioGroup>

        <Spinner
            android:id="@+id/spcategory"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_alignLeft="@+id/edtname"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/edtname"
            android:popupBackground="#000000" />

        <Button
            android:id="@+id/btnsave"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/spiner_reapeat"
            android:layout_centerHorizontal="true"
            android:text="Save" />

        <Spinner
            android:id="@+id/spayfrom"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_alignLeft="@+id/edtduedate"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/edtduedate" />

        <TextView
            android:id="@+id/tv5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignTop="@+id/spayfrom"
            android:layout_marginTop="10dp"
            android:text="Pay From" />

        <TextView
            android:id="@+id/tv4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/edtduedate"
            android:layout_alignBottom="@+id/edtduedate"
            android:layout_alignParentLeft="true"
            android:text="Due Date" />

        <TextView
            android:id="@+id/tv3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/spcategory"
            android:layout_marginTop="25dp"
            android:text="Amount" />

        <TextView
            android:id="@+id/tv2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignTop="@+id/spcategory"
            android:layout_marginTop="10dp"
            android:text="Category" />

</RelativeLayout>
</ScrollView>
jack
  • 338
  • 1
  • 3
  • 29
  • Thanks for Replay I am updated my question I am added a emulator, Please Suggest me – Kuldeep Apr 03 '14 at 11:09
  • close the after last edittext then you can fix it. – jack Apr 03 '14 at 11:12
  • When I close scrollbar after last edit text the show error **Exception raised during rendering: ScrollView can host only one direct child** – Kuldeep Apr 03 '14 at 11:17
  • when u put tag as a first element then you should close it as last. If u want to only four control visible scrollview the u put before "Location" textview and ends with after last edittext. – jack Apr 03 '14 at 11:42
  • Basically scrollview is help for display vertical or horizontal shows cutting items. You need scrollview for only four control which is meaningless. Because those four control is visible for all screen resolutions. \ – jack Apr 03 '14 at 11:49
0

Try this..

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="1"
    android:paddingTop="5dip" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/txtlocation"
            android:layout_width="110dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dip"
            android:text="Location" />

        <EditText
            android:id="@+id/location"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txtlocation"
            android:background="@android:drawable/editbox_background"
            android:ems="10"
            android:singleLine="true" >

            <requestFocus android:layout_width="match_parent" />
        </EditText>

        <TextView
            android:id="@+id/txtminimum"
            android:layout_width="110dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="6.5dip"
            android:text="Minimum Price*" />

        <AutoCompleteTextView
            android:id="@+id/autominimum"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txtminimum"
            android:background="@android:drawable/editbox_background"
            android:ems="10"
            android:singleLine="true" >

            <requestFocus android:layout_width="wrap_content" />
        </AutoCompleteTextView>

        <ImageView
            android:id="@+id/imgminimum"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/autominimum"
            android:layout_alignRight="@+id/autominimum"
            android:layout_alignTop="@+id/autominimum"
            android:src="@drawable/dropdown" />

        <TextView
            android:id="@+id/txtmaximum"
            android:layout_width="110dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dip"
            android:text="Maximum Price*" />

        <AutoCompleteTextView
            android:id="@+id/automaximum"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txtmaximum"
            android:background="@android:drawable/editbox_background"
            android:ems="10"
            android:singleLine="true" >

            <requestFocus />
        </AutoCompleteTextView>

        <ImageView
            android:id="@+id/imgmaximum"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/automaximum"
            android:layout_alignRight="@+id/automaximum"
            android:layout_alignTop="@+id/automaximum"
            android:src="@drawable/dropdown" />

        <TextView
            android:id="@+id/txtproperty"
            android:layout_width="110dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dip"
            android:text="Property Type*" />

        <AutoCompleteTextView
            android:id="@+id/autoproperty"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txtproperty"
            android:background="@android:drawable/editbox_background"
            android:ems="10"
            android:singleLine="true" >

            <requestFocus />
        </AutoCompleteTextView>

        <ImageView
            android:id="@+id/imgproperty"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/autoproperty"
            android:layout_alignRight="@+id/autoproperty"
            android:layout_alignTop="@+id/autoproperty"
            android:src="@drawable/dropdown" />
    </LinearLayout>
</ScrollView>

<Button
    android:id="@+id/btnsearch"
    android:layout_width="100dip"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="20dip"
    android:background="@drawable/rounded"
    android:text="Search"
    android:textColor="#FFFFFF"
    android:textSize="18sp" />

<TextView
    android:id="@+id/txtsigninor"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/btnParent"
    android:layout_margin="5dip"
    android:gravity="center_horizontal"
    android:text="Bfyevfhevf" />

<LinearLayout
    android:id="@+id/btnParent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dip"
    android:gravity="center"
    android:orientation="horizontal"
    android:weightSum="10" >

    <Button
        android:id="@+id/btn_Login1"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_marginBottom="5dp"
        android:background="@drawable/rounded"
        android:gravity="center"
        android:isScrollContainer="false"
        android:text="  Login  "
        android:textColor="#FFFFFF"
        android:textSize="18sp" />

    <Button
        android:id="@+id/btn_register"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_marginBottom="5dp"
        android:background="@drawable/rounded"
        android:gravity="center"
        android:isScrollContainer="false"
        android:text=" Register "
        android:textColor="#FFFFFF"
        android:textSize="18sp" />
</LinearLayout>

Giridharan
  • 4,402
  • 5
  • 27
  • 30
0

use following code. i removed all background you can put it where you want

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="match_parent"

android:paddingLeft="20dip"
android:paddingTop="10dip"
android:paddingRight="20dip"
android:orientation="vertical"

 >
<ScrollView 
    android:layout_height="0px"
    android:layout_width="fill_parent"

    android:paddingTop="5dip"
     android:layout_weight="1"

   >
   <RelativeLayout android:layout_height="wrap_content"
       android:layout_width="match_parent"
      >
    <TextView 
        android:id="@+id/txtlocation"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6dip"

        android:text="Location"/>

    <EditText
        android:id="@+id/location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtlocation"
         android:background="@android:drawable/editbox_background"
         android:singleLine="true"
         android:ems="10" >

        <requestFocus android:layout_width="match_parent" />

    </EditText>




    <TextView 
        android:id="@+id/txtminimum"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6.5dip"
android:layout_below="@+id/location"
        android:text="Minimum Price*"/>

    <AutoCompleteTextView
        android:id="@+id/autominimum"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtminimum"
        android:background="@android:drawable/editbox_background"
        android:ems="10"
        android:singleLine="true" >

        <requestFocus android:layout_width="wrap_content" />

    </AutoCompleteTextView>

   <ImageView
    android:id="@+id/imgminimum"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/autominimum"
    android:layout_alignRight="@+id/autominimum"
    android:layout_alignTop="@+id/autominimum"

    />



    <TextView 
        android:id="@+id/txtmaximum"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6dip"
android:layout_below="@+id/autominimum"
        android:text="Maximum Price*"/>

    <AutoCompleteTextView
        android:id="@+id/automaximum"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtmaximum"
         android:background="@android:drawable/editbox_background"
         android:singleLine="true"
         android:ems="10" >

        <requestFocus />
    </AutoCompleteTextView>

   <ImageView
    android:id="@+id/imgmaximum"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/automaximum"
    android:layout_alignRight="@+id/automaximum"
    android:layout_alignTop="@+id/automaximum"
   />


    <TextView 
        android:id="@+id/txtproperty"
        android:layout_height="wrap_content"
        android:layout_width="110dip"
       android:layout_marginTop="6dip"
 android:layout_below="@+id/automaximum"
        android:text="Property Type*"/>

    <AutoCompleteTextView
        android:id="@+id/autoproperty"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtproperty"
         android:background="@android:drawable/editbox_background"
         android:singleLine="true"
         android:ems="10" >

        <requestFocus />
    </AutoCompleteTextView>

   <ImageView
    android:id="@+id/imgproperty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/autoproperty"
    android:layout_alignRight="@+id/autoproperty"
    android:layout_alignTop="@+id/autoproperty"
   />
  </RelativeLayout>

 </ScrollView>
  <Button
      android:layout_marginTop="20dip"
      android:id="@+id/btnsearch"
      android:layout_width="100dip"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal"

      android:textColor="#FFFFFF"
      android:textSize="18sp"
      android:text="Search" />




      <TextView 
          android:layout_margin="5dip"
           android:id="@+id/txtsigninor"
          android:layout_height="wrap_content"
          android:layout_width="fill_parent"
          android:gravity="center_horizontal"
          android:layout_below="@+id/btnParent"
          android:text="Bfyevfhevf"/>



  <LinearLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_marginBottom="5dip"
  android:gravity="center"
   android:orientation="horizontal"
   android:weightSum="10"
  android:id="@+id/btnParent" >

   <Button
    android:isScrollContainer="false"
    android:id="@+id/btn_Login1"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:layout_marginBottom="5dp"

    android:gravity="center"
    android:textColor="#FFFFFF"
      android:textSize="18sp"
    android:text="  Login  " />

  <Button
    android:isScrollContainer="false"
    android:id="@+id/btn_register"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:layout_marginBottom="5dp"

    android:gravity="center"
    android:text=" Register " 
    android:textColor="#FFFFFF"
      android:textSize="18sp"
    />

  </LinearLayout>
  </LinearLayout>
Pavan
  • 5,016
  • 1
  • 26
  • 30