0

In my one of application,I have to implement scrollview inside a scrollview.I know it is bad practise to use nested scrollview but my application need it.

I have found solution at various place to intercept event like below:

parentScrollView.setOnTouchListener(new View.OnTouchListener() {
  public boolean onTouch(View v, MotionEvent event) {
    Log.v(TAG,"PARENT TOUCH");
    findViewById(R.id.child_scroll).getParent().requestDisallowInterceptTouchEvent(false);
    return false;
  }
});
childScrollView.setOnTouchListener(new View.OnTouchListener() {
  public boolean onTouch(View v, MotionEvent event)
  {
    Log.v(TAG,"CHILD TOUCH");
    //  Disallow the touch request for parent scroll on touch of child view
    v.getParent().requestDisallowInterceptTouchEvent(true);
    return false;
  }
});

But it is also not working.IF anybody have faced same issue and have some solution.Please provide me.

My layout structure is below:

<ScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
     android:focusableInTouchMode="false"
    android:layout_height="wrap_content"
    android:layout_below="@id/topLayoutSaveSchedule"
    android:layout_marginBottom="52dp" >

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

        <LinearLayout
            android:id="@+id/linearLayoutAndroidMess"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal" >

            <CheckBox
                android:id="@+id/checkBoxAndroidMessag"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Copy Sent SMS to Android Messaging"
                android:textColor="@color/Black" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:gravity="center_vertical"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="2dp"
                android:gravity="center_vertical"
                android:text="Selects Contacts:"
                android:textColor="@color/Black"
                android:textSize="14dp" />

            <ScrollView
                android:id="@+id/scrlView"
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:gravity="top"
                android:scrollbars="vertical" >

                <LinearLayout
                    android:id="@+id/linLayout"
                    android:layout_width="150dp"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:padding="5dp"
                    android:orientation="vertical"
                   >
                </LinearLayout>
            </ScrollView>

            <Button
                android:id="@+id/addContacts"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/group_add" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearLayout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:gravity="left"
                android:text="Message:"
                android:textColor="@color/Black"
                android:textSize="14dp" />

            <EditText
                android:id="@+id/text"
                android:layout_width="150dp"
                android:layout_height="15mm"
                android:layout_marginLeft="8mm"
                android:layout_marginTop="10dp"
                android:gravity="top"
                android:inputType="textMultiLine" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearLayout3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/select_date_time"
                android:textColor="@color/Black"
                android:textSize="14dp" />

            <DatePicker
                android:id="@+id/datePicker"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp" />

            <TimePicker
                android:id="@+id/timePicker"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"
                android:text="Repeat/Recurring Option:"
                android:textColor="@color/Blue"
                android:textSize="20dp" />

            <Spinner
                android:id="@+id/spinner1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp" />

            <Button
                android:id="@+id/saveScheduledText"
                android:layout_width="25mm"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="20dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/button_style"
                android:gravity="center"
                android:text="@string/save_scheduled_msg"
                android:textColor="@color/White" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>
GingerHead
  • 8,130
  • 15
  • 59
  • 93
chikka.anddev
  • 9,569
  • 7
  • 38
  • 46
  • http://stackoverflow.com/questions/4490821/scrollview-inside-scrollview http://stackoverflow.com/questions/4490821/scrollview-inside-scrollview/11554823#11554823 – shkschneider Mar 09 '14 at 14:57
  • 1
    You really shouldn't do this. Figure out another way to do what you are doing. – Booger Mar 09 '14 at 14:59
  • I would separate your layouts out into fragments. You can nest fragments without as much of a conflict as you will have from nesting ScrollViews. – zgc7009 May 13 '14 at 18:52

0 Answers0