Is there a way to repeat an image only vertically in android? I’ve tried it like this:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/asphalt_texture"
android:tileMode="repeat"
android:dither="true"/>
But it repeats both ways and I only want it repeated vertically, any ideas would be appreciated!
Strangely enough, there does not seem to be a way to do this in XML. Through code, however, you can. The following methods:
BitmapDrawable.setTileModeX(Shader.TileMode mode)BitmapDrawable.setTileModeY(Shader.TileMode mode)should do what you need. Simply pass in one of the
Shader.TileModeenumerations (REPEAT,MIRROR,CLAMP) for whichever axis (y-axis for vertical) you need the repeat effect on.So you should be able to do something like this: