У меня есть следующий макет XML -
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/checkout_activity_root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
tools:context=".activities.CheckoutActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/activity_checkout_top_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/activity_checkout_back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:contentDescription="@string/marketplace_productvendor_page_back_button"
android:onClick="backButtonPressed"
android:src="@drawable/arrow_left"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/activity_checkout_shopping_cart_framelayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/activity_checkout_cart_imageView"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_margin="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:src="@drawable/icons_32_x_32_black_shopping_cart" />
<TextView
android:id="@+id/activity_checkout_shopping_cart_counter"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="end"
android:background="@drawable/textview_round_background"
android:elevation="1dp"
android:gravity="center"
android:maxLines="1"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="bold"
android:visibility="gone"
app:autoSizeMaxTextSize="16sp"
app:autoSizeMinTextSize="10sp"
app:autoSizeStepGranularity="2sp"
app:layout_constraintStart_toEndOf="@+id/activity_checkout_cart_imageView"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="SmallSp"
tools:text="1"
tools:visibility="visible" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/activity_checkout_top_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/activity_checkout_stages_line"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/activity_checkout_top_layout" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/activity_checkout_top_view">
<LinearLayout
android:id="@+id/activity_checkout_checkout_stages_viewgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="100dp"
android:animateLayoutChanges="true"
android:background="@color/white"
android:orientation="vertical">
<FrameLayout
android:id="@+id/activity_checkout_discount_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:text="@string/activity_checkout_checkout"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/activity_checkout_first_stage_viewgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:id="@+id/activity_checkout_first_stage_textview"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:background="@color/color_black"
android:gravity="center"
android:text="@string/activity_checkout_1"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/activity_checkout_billing_address_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/marketplace_14dp"
android:text="@string/activity_checkout_billing_address"
android:textColor="@color/color_black"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/billing_shipping__address_layout_bottom_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:background="@color/activity_checkout_stages_line" />
<!-- Billing layout -->
<include
android:id="@+id/checkout_activity_billing_address_layout_include"
layout="@layout/fragment_checkout_billing_shipping"
android:visibility="gone" />
<FrameLayout
android:id="@+id/activity_checkout_billing_address_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/activity_checkout_second_stage_viewgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:id="@+id/activity_checkout_second_stage_textview"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:background="@color/activity_checkout_unselected_checkout_stage_color"
android:gravity="center"
android:text="@string/activity_checkout_2"
android:textColor="@color/color_black" />
<TextView
android:id="@+id/activity_checkout_shipping_address_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/marketplace_14dp"
android:text="@string/activity_checkout_shipping_address"
android:textColor="@color/activity_checkout_unselected_checkout_stage_color"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/activity_checkout_shipping_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:background="@color/activity_checkout_stages_line" />
<!-- Shipping layout -->
<include
android:id="@+id/activity_checkout_shipping_address_layout_include"
layout="@layout/fragment_checkout_billing_shipping"
android:visibility="gone" />
<FrameLayout
android:id="@+id/activity_checkout_shipping_address_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/activity_checkout_third_stage_viewgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:id="@+id/activity_checkout_third_stage_textview"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:background="@color/activity_checkout_unselected_checkout_stage_color"
android:gravity="center"
android:text="@string/activity_checkout_3"
android:textColor="@color/color_black" />
<TextView
android:id="@+id/activity_checkout_shipping_method_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/marketplace_14dp"
android:text="@string/activity_checkout_shipping_method"
android:textColor="@color/activity_checkout_unselected_checkout_stage_color"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/activity_checkout_payment_method_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:background="@color/activity_checkout_stages_line" />
<FrameLayout
android:id="@+id/activity_checkout_shipping_method_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/activity_checkout_forth_stage_viewgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:background="@color/activity_checkout_unselected_checkout_stage_color"
android:gravity="center"
android:text="@string/activity_checkout_4"
android:textColor="@color/color_black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/marketplace_14dp"
android:text="@string/activity_checkout_payment_method"
android:textColor="@color/activity_checkout_unselected_checkout_stage_color"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/activity_checkout_payment_information_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:background="@color/activity_checkout_stages_line" />
<LinearLayout
android:id="@+id/activity_checkout_fifth_stage_viewgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:id="@+id/activity_checkout_fifth_stage"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:background="@color/activity_checkout_unselected_checkout_stage_color"
android:gravity="center"
android:text="@string/activity_checkout_5"
android:textColor="@color/color_black" />
<TextView
android:id="@+id/activity_checkout_payment_information"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/marketplace_14dp"
android:text="@string/activity_checkout_payment_information"
android:textColor="@color/activity_checkout_unselected_checkout_stage_color"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/activity_checkout_confirm_order_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:background="@color/activity_checkout_stages_line" />
<FrameLayout
android:id="@+id/activity_checkout_payment_information_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/activity_checkout_sixth_stage_viewgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:id="@+id/activity_checkout_sixth_stage"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:background="@color/activity_checkout_unselected_checkout_stage_color"
android:gravity="center"
android:text="@string/activity_checkout__6"
android:textColor="@color/color_black" />
<TextView
android:id="@+id/activity_checkout_confirm_information_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/marketplace_14dp"
android:text="@string/activity_checkout_confirm_information"
android:textColor="@color/activity_checkout_unselected_checkout_stage_color"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/activity_checkout_confirm_information_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="@dimen/marketplace_14dp"
android:layout_marginTop="@dimen/marketplace_15dp"
android:layout_marginEnd="@dimen/marketplace_14dp"
android:background="@color/activity_checkout_stages_line" />
<FrameLayout
android:id="@+id/activity_checkout_confirm_information_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Это выглядит визуально -
Каждый FrameLayout раздувается с Фрагментом, содержащим содержимое для каждого этапа, то есть это длинный прокручиваемый вид - вот почему я использую NestedScrollView.
Дело в том, что когда я раздуваю нужный фрагмент, мне нужно сосредоточиться и на этом фрагменте. Как запросить фокус и автоматически прокрутить до его позиции?