Android: Autoscrolling HorizontalScrollView

I use the following code to simulate tabs, and since there are more tabs the width of which can accommodate the user, you can scroll left or right to make the tab button visible. This all works, but I also give the user the ability to move between tabs by swiping left or right on the contents of the tab. Again - it works. But when I throw on the extreme right contribution, its corresponding button is barely noticeable. I want the autoscroll table inside HorizontalScrollView, so the selected tab button will be visible, but when I execute HorizontalScrollView.smoothScrollTo(300, 0), nothing happens. No matter how high I set the first parameter x, nothing will ever shift (yes, I have an algorithm to calculate the exact position).

Here is the XML code for scrolling tab buttons

<HorizontalScrollView android:layout_width="fill_parent"
    android:background="@color/tabs_header" android:layout_height="55dip"
    android:scrollbars="none" android:id="@+id/tabsButtonView">
    <TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent" android:layout_weight="1"
            android:layout_height="0dip" android:paddingTop="5dip" android:paddingLeft="3dip">
            <ImageButton android:src="@drawable/linkup_logo_small" android:id="@+id/tabBtt0"
                android:layout_width="wrap_content" android:layout_marginLeft="2dip" android:layout_marginRight="2dip"
                android:layout_height="fill_parent" android:padding="5dip" android:background="@drawable/tab_selected"></ImageButton>
            <ImageButton android:src="@drawable/simplyhired_small" android:id="@+id/tabBtt1"
                android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_marginLeft="2dip"
                android:layout_marginRight="2dip" android:padding="5dip" android:background="@drawable/tab_normal"></ImageButton>
            <ImageButton android:src="@drawable/indeedcom_small" android:id="@+id/tabBtt2"
                android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dip"
                android:layout_marginLeft="2dip" android:layout_marginRight="2dip" android:background="@drawable/tab_normal"></ImageButton>
            <ImageButton android:src="@drawable/careerbuilder_logo_small" android:id="@+id/tabBtt3"
                android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dip"
                android:layout_marginLeft="2dip" android:layout_marginRight="2dip" android:background="@drawable/tab_normal"></ImageButton>
        </TableRow>
    </TableLayout>
</HorizontalScrollView>
+5
1

, HorizontalScrollView autoscrolling . , . .

+2

All Articles