2

I was trying to implement the scrollView and scroll using the scrollbar. But, It isn't working.

This is whole xml file.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".ScrollingActivity"> <ScrollView android:id="@+id/scroll" android:layout_width="wrap_content" android:scrollbars="vertical" android:scrollbarThumbVertical="@color/teal_200" android:scrollbarSize="20dp" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/large_text"/> </ScrollView> </LinearLayout> 

and java is default file.

Main Issue

ScrollBar is appearing and can be seen by user. ScrollBar changes the position as well. But, when User wants to scroll using scrollbar, scrollbar isn't responding. It's like we cannot touch the scrollbar, Instead the textView is selected will be swiped.

My Reasearch

Before anything, I did try to implement GestureDetecter as well as went through several links and google.

  1. How to scroll using custom scrollbars in android WebView?

  2. Gesture detection and ScrollView issue

These are just two links which is most related to my issue. So, I tried to implement customScrollView as well. Which resulted in app crash. There was use of deprecated api too. So, I didn't bother to solve the issue. Instead I focused on replacing that api and getting that class working. But, unfortunately even I got the replacement it wasn't working. I skipped the file because it was way lengthy.

2
  • Are you tried only one TextView with ScrollView? Commented Jun 21, 2021 at 18:24
  • Yes... It's the default large text from scrolling activity in create new project menu. I first tried that project. But, It wasn't working in that too. So, I simplified it. And kept only needed elements. Commented Jun 22, 2021 at 4:32

1 Answer 1

0

You no need to use ScrollBar

Try with is

In you XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".ScrollingActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:scrollbars = "vertical" android:text="@string/large_text"/> </LinearLayout> 

And in your java

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

2 Comments

It's Actually a default large text. Which is too much long. So, textview is scrollable. But, scrollbar is not working. So, textview is indeed exiting the full screen and also scrollable.
This is just a llinear layout layout. It cannot be scrolled....

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.