【问题标题】:Android: Autoscrolling HorizontalScrollViewAndroid:自动滚动 Horizo​​ntalScrollView
【发布时间】:2010-05-19 03:30:40
【问题描述】:

我正在使用以下代码来模拟选项卡,因为有更多宽度可以容纳的选项卡,所以用户可以向左或向右滚动以使选项卡按钮可见。这一切都有效,但是我还为用户提供了通过在选项卡内容上向左或向右滑动手指来在选项卡之间切换的能力。再次 - 它有效。但是当我跳到最右边的标签时,它对应的按钮几乎看不到。我想在HorizontalScrollView 内自动滚动表格,这样选定的选项卡按钮就会可见,但是当我执行HorizontalScrollView.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>

【问题讨论】:

    标签: android autoscroll horizontalscrollview


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多