如何通过不按比例缩放小图像来填充ImageView背景?

Woj*_*hKo 0 android imageview

如何用小图像(例如2x2px)填充整个ImageView背景?
我已经找到了很多答案,如何拉伸图像以填充ImageView,但是我找不到一个如何将多个图像填充以填充整个ImageView的方法。

如果在ImageView中不可能,则可以是其他任何View。

Kel*_*dos 5

为您的图像创建一个位图xml:

drawable / tiled_background.xml

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/your_image"
        android:tileMode="repeat" /> 
Run Code Online (Sandbox Code Playgroud)

注意这android:tileMode="repeat"条线-它会使图像平铺在背景上。现在,简单地将xml分配为背景: