When I touch an EditText I want my scrollView to scrolls some px. The problem is that it only works when I touch the respective EditText the second time and if the focus was on another editText. Here's the code:
KOTLIN:
usernameLogin.setOnFocusChangeListener(object: View.OnFocusChangeListener {
     override fun onFocusChange(view:View, hasFocus:Boolean) {
          if (hasFocus){
             scroll_login.scrollTo(0, 240);
          }else{
             Toast.makeText(getApplicationContext(), "Lost the focus", Toast.LENGTH_LONG).show()
         }
     }
 })
XML
<ScrollView
    android:id="@+id/scroll_login"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 ...
 <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/text_input_usernameLogin"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <EditText
                    android:id="@+id/usernameLogin"
                    android:layout_width="match_parent"
                    android:layout_height="48dp"
                    android:hint="E-mail"
                    android:inputType="textEmailAddress" />
 </com.google.android.material.textfield.TextInputLayout>
 <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:passwordToggleEnabled="true">
                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="48dp"
                    android:hint="Password"
                    android:inputType="textPassword"/>
 </com.google.android.material.textfield.TextInputLayout>
 </ScrollView>
 
    