Skip to content
Permalink
Browse files

Merge branch 'dev'

  • Loading branch information...
beigirad committed May 15, 2018
2 parents 9e7d31e + 874e704 commit fc82a6116f3ca0710d76890d6d0e9b4d95afdb39
@@ -10,9 +10,6 @@ a zigzag view for using for ticket or invoice


# Setup

This library requires `minSdkVersion` to be set to `14` or above, like the [Official Support Library](https://developer.android.com/topic/libraries/support-library/index.html#api-versions).

#### Step #1. Add the JitPack repository to root build.gradle file:

```gradle
@@ -28,7 +25,7 @@ allprojects {

```groovy
dependencies {
compile 'com.github.beigirad:ZigzagView:1.0.3'
implementation 'com.github.beigirad:ZigzagView:1.0.4'
}
```
@@ -41,16 +38,31 @@ dependencies {
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>
```
# Attributes
| Attribute | Type | Default Value | Description |
|:---------------------:|:---------------:|-----------------|:-----------------------------:|
| zigzagHeight | dimension | `0dp` | height of zigzag jags |
| zigzagElevation | dimension | `0dp` | side of shadow |
| zigzagBackgroundColor | color | `Color.WHITE` | background color |
| zigzagPaddingContent | dimension | `0dp` | content padding |
| zigzagPadding | dimension | `0dp` | view padding |
| zigzagPaddingLeft | dimension | `zigzagPadding` | left side view padding |
| zigzagPaddingRight | dimension | `zigzagPadding` | right side view padding |
| zigzagPaddingBottom | dimension | `zigzagPadding` | bottom side view padding |
| zigzagPaddingTop | dimension | `zigzagPadding` | top side view padding |
| zigzagSides | enum | `bottom` | choosing zigzag sides |
| zigzagShadowAlpha | float `[0,1.0]` | `0.5` | amount of shadow transparency |


# Thanks

[**Reza Kardoost**](https://github.com/RezaKardoost) for helping me out with ZigzagView Shadow/Elevation.

# License
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.beigirad'
group = 'com.github.beigirad'


android {
@@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 104
versionName "1.0.4"

}

@@ -24,6 +24,5 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
}
@@ -30,7 +30,6 @@
private static final int ZIGZAG_TOP = 1;
private static final int ZIGZAG_BOTTOM = 2; // default to be backward compatible.Like google ;)

private final String TAG = this.getClass().getSimpleName();
private int zigzagHeight;
private int zigzagElevation;
private int zigzagPaddingContent;
@@ -41,6 +40,7 @@
private int zigzagPaddingTop;
private int zigzagPaddingBottom;
private int zigzagSides;
private float zigzagShadowAlpha;

private Path pathZigzag = new Path();
private Paint paintZigzag;
@@ -77,27 +77,29 @@ public ZigzagView(Context context, @Nullable AttributeSet attrs, int defStyleAtt

private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ZigzagView, defStyleAttr, defStyleRes);
this.zigzagElevation = (int) a.getDimension(R.styleable.ZigzagView_zigzagElevation, 0.0f);
this.zigzagHeight = (int) a.getDimension(R.styleable.ZigzagView_zigzagHeight, 0.0f);
this.zigzagPaddingContent = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingContent, 0.0f);
this.zigzagBackgroundColor = a.getColor(R.styleable.ZigzagView_zigzagBackgroundColor, Color.WHITE);
this.zigzagPadding = (int) a.getDimension(R.styleable.ZigzagView_zigzagPadding, zigzagElevation);
this.zigzagPaddingLeft = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingLeft, zigzagPadding);
this.zigzagPaddingRight = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingRight, zigzagPadding);
this.zigzagPaddingTop = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingTop, zigzagPadding);
this.zigzagPaddingBottom = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingBottom, zigzagPadding);
this.zigzagSides = a.getInt(R.styleable.ZigzagView_zigzagSides, ZIGZAG_BOTTOM);
zigzagElevation = (int) a.getDimension(R.styleable.ZigzagView_zigzagElevation, 0.0f);
zigzagHeight = (int) a.getDimension(R.styleable.ZigzagView_zigzagHeight, 0.0f);
zigzagPaddingContent = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingContent, 0.0f);
zigzagBackgroundColor = a.getColor(R.styleable.ZigzagView_zigzagBackgroundColor, Color.WHITE);
zigzagPadding = (int) a.getDimension(R.styleable.ZigzagView_zigzagPadding, zigzagElevation);
zigzagPaddingLeft = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingLeft, zigzagPadding);
zigzagPaddingRight = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingRight, zigzagPadding);
zigzagPaddingTop = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingTop, zigzagPadding);
zigzagPaddingBottom = (int) a.getDimension(R.styleable.ZigzagView_zigzagPaddingBottom, zigzagPadding);
zigzagSides = a.getInt(R.styleable.ZigzagView_zigzagSides, ZIGZAG_BOTTOM);
zigzagShadowAlpha = a.getFloat(R.styleable.ZigzagView_zigzagShadowAlpha, 0.5f);
a.recycle();

this.paintZigzag = new Paint();
this.paintZigzag.setColor(zigzagBackgroundColor);
this.paintZigzag.setStyle(Style.FILL);
zigzagElevation = Math.min(zigzagElevation, 25);
zigzagShadowAlpha = Math.min(zigzagShadowAlpha, 100);

paintZigzag = new Paint();
paintZigzag.setColor(zigzagBackgroundColor);
paintZigzag.setStyle(Style.FILL);

paintShadow = new Paint(Paint.ANTI_ALIAS_FLAG);
paintShadow.setColorFilter(new PorterDuffColorFilter(BLACK, SRC_IN));
paintShadow.setAlpha(51); // 20%

zigzagElevation = Math.min(zigzagElevation, 25);
paintShadow.setAlpha((int) (zigzagShadowAlpha * 100));

setLayerType(View.LAYER_TYPE_SOFTWARE, null);

@@ -14,5 +14,6 @@
<flag name="top" value="1" />
<flag name="bottom" value="2" />
</attr>
<attr name="zigzagShadowAlpha" format="float" />
</declare-styleable>
</resources>
@@ -13,6 +13,7 @@
app:zigzagBackgroundColor="#8bc34a"
app:zigzagElevation="8dp"
app:zigzagHeight="10dp"
app:zigzagShadowAlpha="0.9"
app:zigzagSides="top|bottom"
app:zigzagPaddingContent="16dp">

BIN +5.58 KB (110%) shot/zigzag.png
Binary file not shown.

0 comments on commit fc82a61

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.