title: How to scroll to center of child of HorizontalScrollView?
body: <p>I need to scroll to the center of childView(TextView) of the HorizontalScrollView.
  i have get the center child by using below code,now i want to adjust arrow to the exact center of that child view.</p>
  
  <p>here, what i've done is i took a HorizontalScrollView and inside it a LineaerLayout and inside the LinearLayout i have TextViews.</p>
  
  <p>here's my XML: </p>
  
  <pre><code> &lt;com.sample.test.ScrollViewCustom
                  android:id="@+id/mHorizontalScrollViewMain"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_alignBottom="@id/relativeOne"
                  android:background="@drawable/mergethree2"
                  android:scrollbars="none" &gt;
  
                  &lt;LinearLayout
                      android:id="@+id/llayoutfirst"
                      android:layout_width="wrap_content"
                      android:layout_height="55dip"
                      android:orientation="horizontal" &gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtHome"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="home"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtSchools"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="schools"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtCalendar"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="calendar"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtActivitiesAndClubs"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="activitiesandclubs"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtBoosters"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="boosters"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtSchoolMenu"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="schoolmenu"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtStaff"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="staff"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtMyFavorites"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="myfavorites"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
  
                      &lt;TextView
                          android:id="@+id/mtxtAboutContact"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginBottom="5dip"
                          android:layout_marginLeft="5dip"
                          android:layout_marginRight="5dip"
                          android:layout_marginTop="8dip"
                          android:text="aboutcontact"
                          android:textColor="@android:color/white"
                          android:textSize="15sp"
                          android:typeface="serif" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="12dip"
                          android:background="@drawable/blackline" /&gt;
                  &lt;/LinearLayout&gt;
          &lt;/com.sample.test.ScrollViewCustom&gt;
  </code></pre>
  
  <p>What i want is, i want the arrow exact at center of TextView which comes at Center of screen.  Like Below.</p>
  
  <p><img src="https://i.stack.imgur.com/egAgT.png" alt="enter image description here"></p>
  
  <p>What i get right now is..</p>
  
  <p><img src="https://i.stack.imgur.com/hvjY5.png" alt="enter image description here"></p>
  
  <p>i have get center of child using following code but now my requirement is to scroll to that child's center of screen. </p>
  
  <p>Here's my Code:</p>
  
  <pre><code>    scroll.setOnScrollStopListner(new onScrollStopListner() {
                      @Override
                      public void onScrollStoped() {
  int scrollX = scroll.getScrollX();
                      int width = lLayOne.getChildAt(1).getWidth();
                      int home = width;
                      int school = width * 2;
                      int calender = width * 3;
                      int activityNclubs = width * 4;
                      int booster = width * 5;
                      int schoolMenu = width * 6;
                      int staff = width * 7;
                      int myFav = width * 8;
                      int about = width * 9;
  
                      if ( scrollX &gt; 0 &amp;&amp; scrollX &lt; home ) {
                          Log.d(TAG, "Home "+" scrollx "+scrollX+" home "+home);
                      }else if ( scrollX &gt; home &amp;&amp; scrollX &lt; school ) {
                          Log.d(TAG, "school"+" scrollx "+scrollX+" school "+school);
                      }else if ( scrollX &gt; school &amp;&amp; scrollX &lt; calender ) {
                          Log.d(TAG, "calender"+" scrollx "+scrollX+" calender "+calender);
                      }else if ( scrollX &gt; calender &amp;&amp; scrollX &lt; activityNclubs ) {
                          Log.d(TAG, "activity n clubs"+" scrollx "+scrollX+" activity "+activityNclubs);
                      }else if ( scrollX &gt; activityNclubs &amp;&amp; scrollX &lt; booster ) {
                          Log.d(TAG, "booster"+" scrollx "+scrollX+" booster "+booster);
                      }else if ( scrollX &gt; booster &amp;&amp; scrollX &lt; schoolMenu ) {
                          Log.d(TAG, "school menu"+" scrollx "+scrollX+" school menu "+schoolMenu);
                      }else if ( scrollX &gt; schoolMenu &amp;&amp; scrollX &lt; staff ) {
                          Log.d(TAG, "staff"+" scrollx "+scrollX+" staff "+staff);
                      }else if ( scrollX &gt; staff &amp;&amp; scrollX &lt; myFav ) {
                          Log.d(TAG, "myFav"+" scrollx "+scrollX+" fav "+myFav);
                      }else if ( scrollX &gt; myFav &amp;&amp; scrollX &lt; about ) {
                          Log.d(TAG, "about"+" scrollx "+scrollX+" about "+about);
                      }                       // TODO Auto-generated method stub
  
  }
              });
  </code></pre>