Android ScrollView, scroll before visible
<p>how can I set scroll of scrollview to x pixels, before it's even shown? </p>

<p>In ScrollView I have some Views and i know that it will fill screen. Can I scroll to let say second View, so that first View is not visible when activity is started?</p>

<p>Now I have sth like this, but I think it's not perfect, sometimes, I see first View, and then it's scrolled to the second one</p>

<pre><code>@Override
public void onGlobalLayout() {
    if (mHorizontalScrollView.getChildCount() &gt; 0 &amp;&amp; mHorizontalScrollView.getChildAt(0).getWidth() &gt; mScreenWidth) {
            hsv.scrollTo(100, 0);
    }
}
</code></pre>

<p>EDIT!!</p>

<p>Second attempt was to use <a href="http://developer.android.com/reference/android/view/ViewTreeObserver.OnPreDrawListener.html" rel="nofollow">http://developer.android.com/reference/android/view/ViewTreeObserver.OnPreDrawListener.html</a> instead of <a href="http://developer.android.com/reference/android/view/ViewTreeObserver.OnGlobalLayoutListener.html" rel="nofollow">http://developer.android.com/reference/android/view/ViewTreeObserver.OnGlobalLayoutListener.html</a>
In <code>OnPreDrawListener</code> we can read that <code>At this point, all views in the tree have been measured and given a frame. Clients can use this to adjust their scroll bounds or even to request a new layout before drawing occurs.</code> so basically at this point we should adjust scrolling. So I created:</p>

<pre><code>@Override
public boolean onPreDraw() {
    if (hsv.getChildCount() &gt; 0 &amp;&amp; hsv.getChildAt(0).getWidth() &gt; mScreenWidth) {
        hsv.scrollTo(100, 0);
        return false;
    }
    return true;
}
</code></pre>

<p>but now it's never working for me.</p>
