Android receipt/zigzag drawable/layout -



Android receipt/zigzag drawable/layout -

i'm in need of creating receipt layout in android. thought simple, rectangle layout zigzag bottom edge.

the best result drawable/layout fixed zigzag size (meaning, fixed half-triangle size), multiply amount of triangles according shape's actual width, in real time. clip maybe, have clipped triangles if necessary.

here illustration (edit: i'm referring bottom zigzag line) :

i have no solid thought of how create it. thought of 9 patch, seems unfitting. thought of list-layer drawable horizontal offsets maybe..

maybe possible create 9 patch separate scale sections, maintain zigzag's aspect ratio... ok.

edit - answer using @luksprog 's comment, recreated wanted. here code:

image (note height corresponds source image size):

<imageview android:id="@+id/zigzag_bottom" android:layout_width="match_parent" android:layout_height="12dp" android:adjustviewbounds="true" android:scaletype="fitxy" android:src="@drawable/zigzag" />

drawable:

<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/ic_zigzag" android:tilemode="repeat" android:antialias="true" />

you can't create 9 path image because there no way define stretchable area on either vertical or horizontal side. obtain zig-zag pattern extract 1 of zig-zag tooth(along it's background shadow) , wrap in bitmapdrawable has tilemode property repeating wrapped image within drawable bounds. way zig-zag tooth repeated , you'll compose pattern.

note height corresponds source image size

this happy scenario, create work case when height doesn't match. illustration wrap zig-zag bitmapdrawable in layerdrawable(along actual view drawable(for rest of view area)) , utilize setlayerinset() place drawable @ bottom. create own drawable places zig-zag pattern image @ bottom overriding ondraw() method.

android android-drawable

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -