Android-Einstellungsposition der hortizontalen Scrollansicht

Ich versuche, die Position der horizontalen Bildlaufansicht so einzustellen, dass sie der gedrückten Schaltfläche entspricht. Ich habe versucht, dies erfolglos einzustellen:

<code>HorizontalScrollView hsv = (HorizontalScrollView)findViewById(R.id.ScrollView);
int x, y;
x = hsv.getLeft();
y = hsv.getTop();
hsv.scrollTo(x, y);
</code>

Dies hat nichts zur Folge, die Scrollansicht bleibt davon unberührt. Die xml:

<code> <HorizontalScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ScrollView"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="@null"
        android:scrollbars="none" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal" >

            <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:layout_marginBottom="-5dp"
                android:text="btn0" 
                android:id="@+id/btn0"
                android:background="@drawable/yellow_btn" />

            <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:layout_marginBottom="-5dp"
                android:background="@drawable/yellow_btn"
                android:text="bnt1"
                android:id="@+id/btn1" />

            <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:layout_marginBottom="-5dp"
                android:background="@drawable/yellow_btn"
                android:text="btn2"
                android:id="@+id/btn2" />

            <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:layout_marginBottom="-5dp"
                android:background="@drawable/yellow_btn"
                android:text="btn3"
                android:id="@+id/btn3" />

      <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:layout_marginBottom="-5dp"
                android:background="@drawable/yellow_btn"
                android:text="btn4"
                android:id="@+id/btn4" />

      <Button
                android:layout_width="100dp"
                android:layout_height="fill_parent"
                android:layout_marginBottom="-5dp"
                android:background="@drawable/yellow_btn"
                android:text="btn5"
                android:id="@+id/btn5" />

        </LinearLayout>
    </HorizontalScrollView>
</code>

Wenn also beim Starten der neuen Aktivität die 5. Taste gedrückt wird (außerhalb des Bildschirms), möchte ich die neue Ansicht so einstellen, dass die horizontale Bildlaufansicht ganz nach rechts und ganz nach links zeigt.

Wie kann ich die Position der horizontalen Bildlaufansicht festlegen?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage