How can we tile a vector image?

后端 未结 5 717
眼角桃花
眼角桃花 2021-02-12 21:02

With the support library now fully supporting vector images, I\'m trying to switch to vector images as much as I can in my app. An issue I\'m running into is that it seems impos

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-12 21:36

    Check Nick Butcher solution:
    https://gist.github.com/nickbutcher/4179642450db266f0a33837f2622ace3
    Add TileDrawable class to your project and then set tiled drawable to your image view:

    // after view created
    val d = ContextCompat.getDrawable(this, R.drawable.pattern)
    imageView.setImageDrawable(TileDrawable(d, Shader.TileMode.REPEAT))
    

提交回复
热议问题