【问题标题】:Keep rotating Horizontal Scroll view保持旋转水平滚动视图
【发布时间】:2012-12-18 11:39:18
【问题描述】:

我在一个活动上附加了一个水平滚动视图和一些图像视图,我希望当加载活动时水平滚动视图中的图像应该从左向右移动,即像横幅表单一样。

这在android中可以吗??

谢谢

【问题讨论】:

    标签: android horizontalscrollview


    【解决方案1】:

    将一些图像文件添加到 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>
    

    【讨论】:

    • 哦,对不起,我弄错了,我会尽力为您的问题找到解决方案
    【解决方案2】:

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

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

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

    这也可能有帮助

    scrollTo(int x, int y)

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多