1

我有一个水平滚动视图,附加了一些关于活动的图像视图,我希望当加载活动时水平滚动视图中的图像应该从左到右移动,即像横幅形式一样。

这在android中可能吗?

谢谢

4

2 回答 2

0

我相信这是可能的。在 scrollView 类里面有一个设置位置的方法

http://developer.android.com/reference/android/widget/ScrollView.html#smoothScrollBy(int , int)

这可能会帮助你。我知道您可能希望改变速度,我正在寻找解决方案。我自己没有尝试过,只是我顺便看到的一种方法

这也可能有帮助

滚动到(int x,int y)

您可以在不同的线程中计算 x 应该每 30 秒在哪里,然后调用 scrollTo(int x, int y) 并传入您想要的数字

于 2012-12-18T14:49:01.067 回答
0

将一些图像文件添加到 res/drawable 文件夹并使用以下布局:

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"

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



<ImageView
     android:src="@drawable/pic1"
     android:id="@+id/img1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     />


<ImageView
     android:src="@drawable/pic2"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     />
<ImageView
     android:src="@drawable/pic3"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     />
<ImageView
     android:src="@drawable/pic4"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     />
</LinearLayout>
</HorizontalScrollView>
于 2012-12-18T11:54:11.573 回答