├── .idea └── vcs.xml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── stx │ │ └── xhb │ │ └── maillineview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── stx │ │ │ └── xhb │ │ │ └── maillineview │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable │ │ └── icon_user_menu_address.png │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── stx │ └── xhb │ └── maillineview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── local.properties ├── mailLineView ├── .gitignore ├── build.gradle ├── mailLineView.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xhb │ │ └── jxnk25 │ │ └── maillineview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xhb │ │ │ └── jxnk25 │ │ │ └── maillineview │ │ │ └── MailLineView.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── xhb │ └── jxnk25 │ └── maillineview │ └── ExampleUnitTest.java ├── sceenshots ├── 001.png └── 002.png └── settings.gradle /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Maillineview 2 | 类似京东收件地址信封分割线 3 | 4 | ### 效果图 5 | 6 | ![ABC](https://github.com/xiaohaibin/Maillineview/blob/master/sceenshots/002.png) 7 | 8 | 9 | ### 使用方式 10 | - Gradle方式引入 11 | ``` 12 | dependencies { 13 | compile 'com.xhb.jxnk25:MailLineView:1.1.0' 14 | } 15 | ``` 16 | - Maven 方式引入 17 | ``` 18 | 19 | com.xhb.jxnk25 20 | MailLineView 21 | 1.0.0 22 | pom 23 | 24 | 25 | ``` 26 | - 直接拷贝代码 27 | 28 | ### xml布局 29 | ``` 30 | 33 | ``` 34 | ### 关于我 35 | 36 | 37 | * **Email**: 38 | * **Home**: 39 | * **掘金**: 40 | * **简书**: 41 | 42 | 43 | 44 | ### 如果觉得文章帮到你,不求打赏,喜欢我的文章可以关注我和朋友一起运营的微信公众号,将会定期推送优质技术文章,求关注~~~ 45 | 46 | ![欢迎关注“大话安卓”微信公众号](http://upload-images.jianshu.io/upload_images/1956769-2f49dcb0dc5195b6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 47 | 48 | ### 欢迎加入“大话安卓”技术交流群,一起分享,共同进步 49 | ![欢迎加入“大话安卓”技术交流群,互相学习提升](http://upload-images.jianshu.io/upload_images/1956769-326c166b86ed8e94.JPG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 50 | 51 | License 52 | -- 53 | Copyright (C) 2016 xhb_199409@163.com 54 | 55 | Licensed under the Apache License, Version 2.0 (the "License"); 56 | you may not use this file except in compliance with the License. 57 | You may obtain a copy of the License at 58 | 59 | http://www.apache.org/licenses/LICENSE-2.0 60 | 61 | Unless required by applicable law or agreed to in writing, software 62 | distributed under the License is distributed on an "AS IS" BASIS, 63 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 64 | See the License for the specific language governing permissions and 65 | limitations under the License. 66 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.stx.xhb.maillineview" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.0.1' 26 | compile project(':mailLineView') 27 | } 28 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/stx/xhb/maillineview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.stx.xhb.maillineview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/stx/xhb/maillineview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.stx.xhb.maillineview; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_main); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_user_menu_address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/app/src/main/res/drawable/icon_user_menu_address.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 14 | 19 | 24 | 30 | 37 | 38 | 41 | 45 | 51 | 52 | 53 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MailLineView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/stx/xhb/maillineview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.stx.xhb.maillineview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.0.0' 9 | classpath 'com.novoda:bintray-release:0.3.4' 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file should *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=D\:\\Android\\AndroidSDK -------------------------------------------------------------------------------- /mailLineView/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /mailLineView/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | android { 3 | compileSdkVersion 23 4 | buildToolsVersion "23.0.1" 5 | 6 | defaultConfig { 7 | minSdkVersion 15 8 | targetSdkVersion 23 9 | versionCode 1 10 | versionName "1.0" 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | compile fileTree(dir: 'libs', include: ['*.jar']) 22 | testCompile 'junit:junit:4.12' 23 | compile 'com.android.support:appcompat-v7:23.0.1' 24 | } 25 | -------------------------------------------------------------------------------- /mailLineView/mailLineView.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /mailLineView/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /mailLineView/src/androidTest/java/com/xhb/jxnk25/maillineview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xhb.jxnk25.maillineview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /mailLineView/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /mailLineView/src/main/java/com/xhb/jxnk25/maillineview/MailLineView.java: -------------------------------------------------------------------------------- 1 | package com.xhb.jxnk25.maillineview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Path; 8 | import android.util.AttributeSet; 9 | import android.view.View; 10 | 11 | /** 12 | * time 2016-08-03 13 | * @author xhb 14 | * decribe:收件地址信封分割线 15 | */ 16 | public class MailLineView extends View { 17 | 18 | private int colorWidth = 7;//颜色区域宽度 19 | private int emptyWidth = 1;//间隔宽度 20 | private Paint paint; 21 | private Path path; 22 | 23 | public MailLineView(Context context, AttributeSet attrs, int defStyleAttr) { 24 | super(context, attrs, defStyleAttr); 25 | initPaint(); 26 | } 27 | 28 | public MailLineView(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | initPaint(); 31 | } 32 | 33 | public MailLineView(Context context) { 34 | super(context); 35 | initPaint(); 36 | } 37 | 38 | /** 39 | * 初始化画笔 40 | */ 41 | public void initPaint(){ 42 | paint = new Paint(); 43 | paint.setAntiAlias(true); 44 | } 45 | @Override 46 | protected void onDraw(Canvas canvas) { 47 | 48 | int viewHeight = getHeight(); 49 | int drawLength = 0; 50 | int count = 0; 51 | while (drawLength < getWidth()) { 52 | drawLength += emptyWidth * viewHeight; 53 | count++; 54 | /*设置paint的颜色*/ 55 | if (count % 2 == 1) { 56 | paint.setColor(Color.rgb(255, 134, 134)); 57 | } else { 58 | paint.setColor(Color.rgb(134, 194, 255)); 59 | } 60 | /*开始画多边形*/ 61 | path = new Path(); 62 | path.moveTo(drawLength, viewHeight);// 此点为多边形的起点 63 | path.lineTo(drawLength + colorWidth * viewHeight - viewHeight, viewHeight); 64 | path.lineTo(drawLength + colorWidth * viewHeight, 0); 65 | path.lineTo(drawLength + viewHeight, 0); 66 | path.close(); // 使这些点构成封闭的多边形 67 | canvas.drawPath(path, paint); 68 | drawLength += colorWidth * viewHeight; 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /mailLineView/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | mailLineView 3 | 4 | -------------------------------------------------------------------------------- /mailLineView/src/test/java/com/xhb/jxnk25/maillineview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.xhb.jxnk25.maillineview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /sceenshots/001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/sceenshots/001.png -------------------------------------------------------------------------------- /sceenshots/002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohaibin/Maillineview/fd02d21bb760fc63ed625ee81e6796c01c98e559/sceenshots/002.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':mailLineView' 2 | --------------------------------------------------------------------------------