我有一个 HorizontalScrollview,我想要一个可重复的图像,所以我可以向左或向右无限滚动。这是我的 XML 代码
<HorizontalScrollView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageview_scroll"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
</HorizontalScrollView>
这是我的Java代码
ImageView imageView = findViewById(R.id.imageview_scroll);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.scroll);
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
bitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);
imageView.setImageBitmap(bitmap);
但是,此代码仅显示一次图像并且不会重复。
我怎样才能做到这一点?