gpt4 book ai didi

Android:自动滚动 Horizo​​ntalScrollView

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:08:52 25 4
gpt4 key购买 nike

我正在使用以下代码来模拟选项卡,因为有更多的选项卡宽度可以容纳用户可以向左或向右滚动以使选项卡按钮可见。一切正常,但是我还为用户提供了通过在选项卡内容上向左或向右滑动手指来在选项卡之间切换的能力。再次 - 它有效。但是当我飞到最右边的标签时,它对应的按钮几乎看不见。我想在 Horizo​​ntalScrollView 内自动滚动表格,这样所选的选项卡按钮将可见,但是当我执行 Horizo​​ntalScrollView.smoothScrollTo(300, 0) 时,什么也没有发生。无论我将第一个 x 参数设置多高都不会移动(是的,我确实有一个算法来计算精确位置)。

这是滚动标签按钮的 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>

最佳答案

Horizo​​ntalScrollView 没有任何问题,自动滚动功能运行良好。这只是我的代码中失败的一系列初始化。结案。

关于Android:自动滚动 Horizo​​ntalScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2862662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com