0

I Am Making A Note Saver Application, For The Main Body of Note I Am Using A Multiline EditText Looks Like This:- Screenshot

Code For EditText:-

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    <com.mnotes.view.TextField
        android:id="@+id/mNoteEditText"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@null"
        android:gravity="top|start"
        android:inputType="textMultiLine"
        android:overScrollMode="always"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:scrollHorizontally="false"
        android:hint="Start Writing For Here...."
        android:padding="8dp"
        android:clickable="true"
        android:focusable="true"
        android:fontFamily="sans-serif-smallcaps"
        android:longClickable="true"
        android:textIsSelectable="true"/>
    </LinearLayout>

When I Scroll This EditText It Gains Focus Which Makes Softkey Popup, This Behaviour Makes The Scrolling Experience Very Bad.So I Want To Disable Focus On EditText While Scrolling, Please Help.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Shashank Mishra
  • 542
  • 4
  • 12
  • See this https://stackoverflow.com/questions/8181828/android-detect-when-scrollview-stops-scrolling, They have implemented scroll view with listeners to onScroll start and onScrollStop, you can use them to enable disable focus of the edit text – Ashish Kumar Apr 15 '18 at 07:27

1 Answers1

1

I found a solution (only works on short texts). You can use the ScrollView onScrollChange event. This is how I did it:

ScrollView scroll = findViewById(R.id.scrollView1);
    scroll.setOnScrollChangeListener(new View.OnScrollChangeListener() {
        @Override
        public void onScrollChange(View view, int i, int i1, int i2, int i3) {
            et.clearFocus();
        }
    });

The variable et is an EditText object.