title: How to make an item in a ScrollView be positioned in the center of the screen
body: <p>I have three <code>CardView</code> in a <code>HorizontalScrollView</code> and I want the middle one to be in the center of the screen (as if the user had swiped to get to it). How do I do that in <code>XML</code> or programmatically?</p>
  
  <p>XML layout:</p>
  
  <pre><code>&lt;HorizontalScrollView
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginStart="16dp"
      android:layout_marginTop="8dp"
      android:layout_marginEnd="16dp"
      android:scrollbars="none"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/culture_toolbar"&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"&gt;
  
          &lt;androidx.cardview.widget.CardView
              android:id="@+id/one"
              android:layout_width="300dp"
              android:layout_height="300dp"
              android:layout_marginEnd="10dp"
              app:cardCornerRadius="12dp"&gt;
  
              &lt;ImageView
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:scaleType="fitXY"
                  android:src="@drawable/beach_bg_placeholder" /&gt;
  
          &lt;/androidx.cardview.widget.CardView&gt;
  
          &lt;androidx.cardview.widget.CardView
              android:id="@+id/two"
              android:layout_width="300dp"
              android:layout_height="300dp"
              app:cardCornerRadius="12dp"&gt;
  
              &lt;ImageView
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:scaleType="fitXY"
                  android:src="@drawable/beach_bg_placeholder" /&gt;
  
          &lt;/androidx.cardview.widget.CardView&gt;
  
          &lt;androidx.cardview.widget.CardView
              android:id="@+id/three"
              android:layout_width="300dp"
              android:layout_height="300dp"
              app:cardCornerRadius="12dp"&gt;
  
              &lt;ImageView
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:scaleType="fitXY"
                  android:src="@drawable/beach_bg_placeholder" /&gt;
  
          &lt;/androidx.cardview.widget.CardView&gt;
      &lt;/LinearLayout&gt;
  &lt;/HorizontalScrollView&gt;
  </code></pre>
  
  <p>This is the result I'm going for:</p>
  
  <p><a href="https://i.stack.imgur.com/83Nr2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/83Nr2.png" alt="I want the upper half the mockup"></a></p>