1

アクティビティのいくつかの画像ビューが添付された1つの水平スクロールビューがあり、アクティビティが読み込まれたときに、水平スクロールビューの画像が左から右に移動する必要があります。つまり、バナーフォームのようになります。

これはAndroidで可能ですか?

ありがとう

4

2 に答える 2

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 に答える
0

可能だと思います。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) を呼び出して、必要な数値を渡すことができます

于 2012-12-18T14:49:01.067 に答える