Android Make a part of the image reproduced in android?

I want to achieve something similar to the following: enter image description here

Note that the image pattern to the right of the triangle repeats until it hits the edge of the screen. In addition, the triangle will not actually be a triangle (i.e. the image will not be a simple shape), so please keep this in mind. I am completely new to Android and I know that in iOS you can set a portion of an image to repeat. I'm not sure if this is true for Android as well, and if so, how? If not, what would be the recommended approach?

+5
source share
2 answers

To repeat the image, you can set the TileMode for this bitmap. To move it to your right in your case, you can define a drop-down list of layers and give its element the left property:

tile_background.xml

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <bitmap android:src="@drawable/tile_start" android:gravity="left|bottom"/> </item> <item android:left="60px"> <bitmap android:src="@drawable/tile" android:tileMode="repeat"/> </item> </layer-list> 

just a layout:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <View android:id="@+id/view1" android:layout_width="wrap_content" android:layout_height="26dp" android:background="@drawable/tiled_background" /> </LinearLayout> 

enter image description here

+6
source

If I understand correctly, you can take a look at the NinePatch images http://developer.android.com/reference/android/graphics/NinePatch.html

The nine images of the patches are smart in the sense that they can have certain boundaries that can be stretched and repeated as necessary. Here is a quick tool that can give a better idea of ​​this, http://romannurik.imtqy.com/AndroidAssetStudio/nine-patches.html

+2
source

Source: https://habr.com/ru/post/1205778/


All Articles