1

I`m have a problem just like this one:

Stop ScrollView from auto-scrolling to an EditText

I have Layout inside a ScrollView. In this layout there`s a lot of diffetent views (EditText, Spinners, etc...)

If a EditText has the focus and then I select a item from a Spinner, the display auto-scroll back to the EditText that have the focus.

Putting this code in the Layout parameters, solves the problem in most cases.

android:focusable="true"
android:focusableInTouchMode="true"

BUT...

My layout is a Constraint Layout and what is happening is that all EditText that have a 0dp ("match_constraint") size, or "match_parent" are still doing the auto-scroll to it. And the EditText that have a fixed size ou "wrap_content" works fine.

"This Layout is inside a ScrollView"
<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true">

    "This EditText, if have focus, make the auto-scroll to it"
    <EditText
        android:id="@+id/edtText1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:inputType="text"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="someView"/>

    "This EditText, if have focus, DO NOT make a auto-scroll to it"
    <EditText
        android:id="@+id/edtText2"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:inputType="text"
        app:layout_constraintTop_toBottomOf="@+id/edtText1"
        app:layout_constraintStart_toStartOf="parent"/>
...
...
...
...
    "Spinner at the end of Layout that i'm selecting a item..."
    <Spinner....

Again... If I'm Using a Linear or Relative layout, the solution works fine... But when using the Constraint layout works for some EditText and others NOT, and the tests that I have made point to the fact that some EditText use a match_constraint size or somthing related to it..

Any one else having this same problem or able to replicate the problem that is happening here only with the Constraint layout ???

Thanks

Somesh Kumar
  • 8,088
  • 4
  • 33
  • 49

0 Answers0