Scroll view implemented on specific linear layout and relative layout

0 votes
asked Sep 10, 2017 by machine-guy

I am trying to scroll the relative layout using linear layout as child ayour and scroll view as parent to both of them, but unable to scroll the specific part of the layout. My code is attached below, plese guide me through it.

I have tried every options, although dont want to use Android ListView Checkbox, there's a little bit of problem with this layout, please help me to figure it out.

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.noumannaeem.mistreemazdoor.mistremazdoortest2.SearchFilterActivity"
tools:showIn="@layout/activity_search_filter">



<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView">

<TextView
    android:layout_width="130dp"
    android:layout_height="wrap_content"
    android:paddingRight="@dimen/activity_horizontal_margi"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Work Category"
    android:id="@+id/textView8"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:layout_marginStart="20dp"
    android:layout_marginTop="20dp" />

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginEnd="20dp"
        android:id="@+id/spinner2"
        android:background="@color/button_material_light"
        android:clickable="true"
        android:layout_marginTop="10dp"
        android:layout_below="@+id/textView8"
        android:layout_alignStart="@+id/textView8" />


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Worker Rating"
    android:id="@+id/textView9"
    android:layout_marginTop="30dp"
    android:layout_marginEnd="20dp"
    android:layout_below="@+id/spinner2"
    android:layout_alignStart="@+id/spinner2" />

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView9"
    android:layout_alignStart="@+id/textView9"
    android:layout_marginTop="10dp"
    android:layout_marginEnd="20dp"
    android:orientation="horizontal"
    android:id="@+id/radioGroup">


    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=">= 1"
        android:id="@+id/radioButton"
        android:checked="false"
        android:layout_weight="0.13" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="> 2"
        android:id="@+id/radioButton2"
        android:checked="false"
        android:layout_weight="0.13" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="> 3"
        android:id="@+id/radioButton3"
        android:checked="false"
        android:layout_weight="0.13" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="> 4"
        android:id="@+id/radioButton4"
        android:checked="false"
        android:layout_weight="0.13" />



</RadioGroup>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Location"
    android:id="@+id/textView10"
    android:layout_below="@+id/radioGroup"
    android:layout_alignStart="@+id/radioGroup"
    android:layout_marginEnd="20dp"
    android:layout_marginTop="30dp" />

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton2"
    android:src="@drawable/placeholder"
    android:background="@null"
    android:layout_alignTop="@+id/autoCompleteTextView"
    android:layout_alignEnd="@+id/radioGroup" />

<AutoCompleteTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="Enter your location"
    android:textSize="18dp"
    android:id="@+id/autoCompleteTextView"
    android:layout_below="@+id/textView10"
    android:layout_alignLeft="@+id/radioGroup"
    android:layout_toStartOf="@+id/imageButton2"
    android:inputType="textMultiLine" />


</RelativeLayout>


<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/scrollView">   // this scroll view is not performing it's action

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="150dp">

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  1"
    android:id="@+id/checkBox"
    android:layout_alignParentStart="true"
    android:layout_marginStart="20dp"
    android:layout_marginTop="10dp" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  2"
    android:id="@+id/checkBox2"
    android:layout_marginStart="35dp"
    android:layout_alignTop="@+id/checkBox"
    android:layout_toEndOf="@+id/checkBox" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  3"
    android:id="@+id/checkBox3"
    android:layout_marginStart="35dp"
    android:layout_alignTop="@+id/checkBox2"
    android:layout_toEndOf="@+id/checkBox2" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  4"
    android:id="@+id/checkBox4"
    android:layout_below="@+id/checkBox"
    android:layout_alignStart="@+id/checkBox"
    android:layout_marginTop="20dp" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  5"
    android:id="@+id/checkBox5"
    android:layout_alignTop="@+id/checkBox4"
    android:layout_alignStart="@+id/checkBox2" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  6"
    android:id="@+id/checkBox6"
    android:layout_alignTop="@+id/checkBox5"
    android:layout_alignStart="@+id/checkBox3" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  7"
    android:id="@+id/checkBox7"
    android:layout_below="@+id/checkBox4"
    android:layout_alignStart="@+id/checkBox4"
    android:layout_marginTop="20dp" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  8"
    android:id="@+id/checkBox8"
    android:layout_alignTop="@+id/checkBox7"
    android:layout_alignStart="@+id/checkBox5" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New  9"
    android:id="@+id/checkBox9"
    android:layout_alignTop="@+id/checkBox8"
    android:layout_alignStart="@+id/checkBox6" />



    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New  10"
        android:id="@+id/checkBox10"
        android:layout_below="@+id/checkBox7

1 Answer

0 votes
answered Sep 10, 2017 by bhuvanesh-bs

Remove the LinearLayout from your scrollview and set the height to ScrollView.

<ScrollView
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:layout_below="@+id/scrollView"> 

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
              ............
              ............
            </RelativeLayout>
    </ScrollView>

Hope it helps:)

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...