2

My EditText can have sometimes very large text (>1000 lines) and I want to be able to quickly reach the start or the end so I thought fast scroll was the solution, however it is not available for EditText, nor ScrollView, only for ListView. I found some editing apps that do have the fast scroll bar in their EditText. How did they do it? Setting smoothScrollEnabled on parent ScrollView doesn't work

Nicolas
  • 6,611
  • 3
  • 29
  • 73

2 Answers2

2

By quoting this,

You can use a ScrollView and place your EditText inside it and mention the position of it that you need fast/smooth scrolling.

    scrollview = (ScrollView) findViewById(R.id.scroll_view) ;
    scrollview.setSmoothScrollingEnabled ( true );
    scrollview.smoothScrollBy (int dx, int dy); //dx,dy.. offset (Relative Position)
    scrollview.smoothScrollTo (int x, int y); //scroll to x and y (actual position)
Community
  • 1
  • 1
Charuක
  • 12,953
  • 5
  • 50
  • 88
  • Do I have to make the scrollbar myself? If so, how? – Nicolas Jan 15 '17 at 02:57
  • scrollbar or ScrollView? yes you need to add your edit text inside ScrollView – Charuක Jan 15 '17 at 03:08
  • I mean will that add a scrollbar like the one added in ListView when using fast scroll? Or are you only suggesting a way to scroll manually? – Nicolas Jan 16 '17 at 02:31
  • @Nicolas Maltais try and see you can use fast scroll with that and those possition with starts that can be given by relatively or you can give the actual position ,if you dont need a scroll bar i guess you can remove that as well – Charuක Jan 16 '17 at 02:36
  • No that doesn't change anything, I want a draggable scrollbar to appear, like with listView's fastScroll – Nicolas Jan 20 '17 at 22:37
  • 3
    Please update your question. You should mention the scrollbar in your question to get relevent answers. – Anis LOUNIS aka AnixPasBesoin Jan 25 '17 at 02:54
0
<ScrollView
    android:id="@+id/scrollViewEditText"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="60dp"
    android:layout_marginBottom="60dp"
    android:fillViewport="true"
    android:scrollbarThumbHorizontal="@null"
    android:scrollbarThumbVertical="@null"
    android:visibility="visible">

    <EditText
        android:id="@+id/etBook"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="15dp"
        android:background="@null"
        android:fastScrollEnabled="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:fontFamily="@font/futurabook"
        android:gravity="top"
        android:hint="Tap to start writing ...."
        android:importantForAutofill="no"
        android:inputType="textMultiLine"
        android:lineSpacingExtra="0sp"
        android:minHeight="48dp"
        android:textColor="@color/colorSecondaryVariant"
        android:textSize="17sp"
        tools:ignore="SpeakableTextPresentCheck" />

</ScrollView>
sandip
  • 394
  • 1
  • 4
  • 11