5
我使用下面的代码来模拟标签,因为有更多的标签,宽度可以容纳用户可以滚动左侧或右侧,使一个标签按钮可见。这一切都有效,但是我还可以通过在选项卡内容上向左或向右滑动手指,为用户提供在选项卡之间进行漫游的功能。再次 - 它的作品。但是当我扔到最右边的标签时,它的相应按钮几乎看不见。我想在HorizontalScrollView
里自动滚动表格,这样选中的选项卡按钮就会显示出来,但是当我执行HorizontalScrollView.smoothScrollTo(300, 0)
时,什么都不会发生。不管我第一次设置多高,参数什么都不会移动(是的,我确实有算法来计算确切的位置)。Android:Autoscrolling HorizontalScrollView
这里的XML代码滚动标签按钮
<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>