Android Zig-Zag layout
Asked Answered
A

3

8

I'm in need of creating a receipt layout in Android. The idea is very simple, a rectangle layout with a zigzag top.

enter image description here

Even, i have tried dashed line but nothing working.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="line">

<stroke
   android:color="#FF00"
   android:dashWidth="5dp"
   android:dashGap="5dp" />
</shape>
Alanealanine answered 26/10, 2016 at 4:37 Comment(3)
Duplicate of #28761679Lilytrotter
@SlowAndSteady i have seen this post earlier but it didnt help.Alanealanine
Hey! did you solve your problem...If yes can you please tell me howKilian
G
7

Try with this: https://github.com/beigirad/ZigzagView

Support top and bottom Zigzag.

<ir.beigirad.zigzagview.ZigzagView
    android:layout_width="match_parent"
    android:layout_height="240dp"
    app:zigzagBackgroundColor="#8bc34a"
    app:zigzagElevation="8dp"
    app:zigzagHeight="10dp"
    app:zigzagShadowAlpha="0.9"
    app:zigzagSides="top|bottom"
    app:zigzagPaddingContent="16dp">

    // add child view(s)

</ir.beigirad.zigzagview.ZigzagView>

ZizagView

Glaswegian answered 16/5, 2018 at 17:23 Comment(0)
A
2

Hi you can use this library android-shape-imageview. And use transparent shape like this

End use library.

enter image description here

<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:siShape="@drawable/zigzag"
android:src="@drawable/neo"
app:siSquare="true"/>

enter image description here

You can change app:siShape="@drawable/zigzag" to desired shape. You can create other png shape.

Atomicity answered 26/10, 2016 at 4:54 Comment(2)
i dont want zig zag at all the 4 corners. Only top. Hence, this wont work for me.ThanksAlanealanine
i also want top two corners(top left and top right) to be rounded/curved...what will be my approch?Ouch
E
1

Create small triangle and use repeat background

repeat_background.xml

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

and use it in any view

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/repeat_background" />

refer this and this for more

Endorsement answered 26/10, 2016 at 4:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.