1

I am developing 1 application in that i need 1 scrollview inside this scrollview i need to put scrolling textview/webview(that must display some static string) but must scrollable inside scrollview but not working

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@color/white" >  
    <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/img_view_flag"
            android:layout_marginTop="17dp" 
            android:paddingBottom="20dip">

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



                    <TextView
                        android:id="@+id/tv_desc"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_below="@+id/rel_layout"
                        android:layout_marginTop="15dp"
                        android:maxLines="2"
                        android:scrollbars="vertical"
                        android:text="Medium Text"
                        android:paddingBottom="10dip"
                         android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/black" />
     </LinearLayout>
        </ScrollView>

    </RelativeLayout>

In myjava file i have done...

scrollView1 = (ScrollView) findViewById(R.id.scrollView1);
    // scrollView2 = (ScrollView) findViewById(R.id.scrollView2);
    tv = (TextView) findViewById(R.id.tv_desc);
    tv.setText("this is 1\n"+"this is 2"+"\n this ix 3\n"+"this is 4\n\n"+"this is 5\n" );

    scrollView1.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            // TODO Auto-generated method stub Log.v("PARENT",
            // "PARENT TOUCH");
            Log.v("PARENT", "PARENT TOUCH");
            findViewById(R.id.tv_desc).getParent()
                    .requestDisallowInterceptTouchEvent(false);
            return false;
        }
    });
    tv.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            Log.v("TextView", "CHILD TOUCH");
            arg0.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });

But not working for me.... what wrong or what i am missing?

1

2 Answers 2

5

You have to use below line in your code to make textview scrollable..

yourTextView.setMovementMethod(new ScrollingMovementMethod())
Sign up to request clarification or add additional context in comments.

Comments

-1

Found a solution.

Add following lines towards end of your OnCreate() function

    scrollView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            textView.getParent().requestDisallowInterceptTouchEvent(false);

            return false;
        }
    });

    textView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            textView.getParent().requestDisallowInterceptTouchEvent(true);

            return false;
        }
    });

1 Comment

This is exactly what the OP has done and just as he says, it doesn't work. You need to add Riser's line from the ^ post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.