Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
beigirad committed May 15, 2018
2 parents 9e7d31e + 874e704 commit fc82a61
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
22 changes: 17 additions & 5 deletions README.md
Expand Up @@ -10,9 +10,6 @@ a zigzag view for using for ticket or invoice




# Setup # 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: #### Step #1. Add the JitPack repository to root build.gradle file:


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


```groovy ```groovy
dependencies { dependencies {
compile 'com.github.beigirad:ZigzagView:1.0.3' implementation 'com.github.beigirad:ZigzagView:1.0.4'
} }
``` ```
Expand All @@ -41,16 +38,31 @@ dependencies {
app:zigzagBackgroundColor="#8bc34a" app:zigzagBackgroundColor="#8bc34a"
app:zigzagElevation="8dp" app:zigzagElevation="8dp"
app:zigzagHeight="10dp" app:zigzagHeight="10dp"
app:zigzagShadowAlpha="0.9"
app:zigzagSides="top|bottom"
app:zigzagPaddingContent="16dp"> app:zigzagPaddingContent="16dp">


// add child view(s) // add child view(s)


</ir.beigirad.zigzagview.ZigzagView> </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 # Thanks

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


# License # License
Expand Down
7 changes: 3 additions & 4 deletions library/build.gradle
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'
group='com.github.beigirad' group = 'com.github.beigirad'




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


} }


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


dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:appcompat-v7:26.1.0'
} }
36 changes: 19 additions & 17 deletions library/src/main/java/ir/beigirad/zigzagview/ZigzagView.java
Expand Up @@ -30,7 +30,6 @@ public class ZigzagView extends FrameLayout {
private static final int ZIGZAG_TOP = 1; private static final int ZIGZAG_TOP = 1;
private static final int ZIGZAG_BOTTOM = 2; // default to be backward compatible.Like google ;) 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 zigzagHeight;
private int zigzagElevation; private int zigzagElevation;
private int zigzagPaddingContent; private int zigzagPaddingContent;
Expand All @@ -41,6 +40,7 @@ public class ZigzagView extends FrameLayout {
private int zigzagPaddingTop; private int zigzagPaddingTop;
private int zigzagPaddingBottom; private int zigzagPaddingBottom;
private int zigzagSides; private int zigzagSides;
private float zigzagShadowAlpha;


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


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


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


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

zigzagElevation = Math.min(zigzagElevation, 25);


setLayerType(View.LAYER_TYPE_SOFTWARE, null); setLayerType(View.LAYER_TYPE_SOFTWARE, null);


Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Expand Up @@ -14,5 +14,6 @@
<flag name="top" value="1" /> <flag name="top" value="1" />
<flag name="bottom" value="2" /> <flag name="bottom" value="2" />
</attr> </attr>
<attr name="zigzagShadowAlpha" format="float" />
</declare-styleable> </declare-styleable>
</resources> </resources>
1 change: 1 addition & 0 deletions sample/src/main/res/layout/activity_main.xml
Expand Up @@ -13,6 +13,7 @@
app:zigzagBackgroundColor="#8bc34a" app:zigzagBackgroundColor="#8bc34a"
app:zigzagElevation="8dp" app:zigzagElevation="8dp"
app:zigzagHeight="10dp" app:zigzagHeight="10dp"
app:zigzagShadowAlpha="0.9"
app:zigzagSides="top|bottom" app:zigzagSides="top|bottom"
app:zigzagPaddingContent="16dp"> app:zigzagPaddingContent="16dp">


Expand Down
Binary file modified shot/zigzag.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc82a61

Please sign in to comment.