android:focusable=”true”
android:focusableInTouchMode=”true”
add these two line in parent of the Edittext …in example we added into cardview.
<androidx.cardview.widget.CardView
android:id="@+id/note_search_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="5dp"
app:cardBackgroundColor="@color/whiteBgcolor"
app:cardCornerRadius="5dp"
app:cardElevation="3dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:focusable="true"
android:focusableInTouchMode="true">
<EditText
android:id="@+id/note_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/bg_white_border_no"
android:hint="Search Note by title.."
android:imeOptions="actionSearch"
android:inputType="text"
android:padding="8dp"
android:textSize="15sp" />
</androidx.cardview.widget.CardView>
Auto focus on edittext inside scrollview
autofocus inside scrollview