├── .gitattributes ├── .gitignore ├── README.md └── RadarScanView ├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── RadarScanView.iml ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── guo │ │ └── duoduo │ │ └── radarscanview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── guo │ │ │ └── duoduo │ │ │ └── radarscanview │ │ │ ├── MainActivity.java │ │ │ └── RefreshProgressActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_refresh_progress.xml │ │ └── content_refresh_progress.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── guo │ └── duoduo │ └── radarscanview │ └── ExampleUnitTest.java ├── build.gradle ├── gif ├── radar.gif └── radarscan.gif ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── library.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── guo │ │ └── duoduo │ │ └── library │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── guo │ │ │ └── duoduo │ │ │ └── library │ │ │ ├── LinearAnimation.java │ │ │ ├── RadarScanView.java │ │ │ └── RefreshProgress.java │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── guo │ └── duoduo │ └── library │ └── ExampleUnitTest.java ├── randomtextview ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── randomtextview.iml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── guo │ │ └── duoduo │ │ └── randomtextview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── guo │ │ │ └── duoduo │ │ │ └── randomtextview │ │ │ └── RandomTextView.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── guo │ └── duoduo │ └── randomtextview │ └── ExampleUnitTest.java ├── rippleview ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── rippleview.iml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── guo │ │ └── duoduo │ │ └── rippleoutview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── guo │ │ │ └── duoduo │ │ │ └── rippleoutview │ │ │ └── RippleView.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── guo │ └── duoduo │ └── rippleoutview │ └── ExampleUnitTest.java └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RadarScanView 2 | 自定义View之雷达扫描 3 | 4 | 5 | 6 | ## 原理 7 | 关键是使用SweepGradient进行扫描渲染 8 | 关键代码如下: 9 | 10 | ```JAVA 11 | Shader shader = new SweepGradient(centerX, centerY, Color.TRANSPARENT, tailColor); 12 | mPaintRadar.setShader(shader); 13 | ``` 14 | 然后旋转起来即可 15 | 16 | ```JAVA 17 | matrix.postRotate(start, centerX, centerY); 18 | ``` 19 | 20 | 代码中包含了如何自定义一个View,怎样重写onMeasure、onSizeChanged、onDraw函数、自定义属性等等知识点 21 | 22 | ## 效果图 23 | 24 | ![image](https://github.com/gpfduoduo/RadarScanView/blob/master/RadarScanView/gif/radar.gif "效果图") 25 | 26 | ## 添加动态显示效果 27 | 28 | ```JAVA 29 | new Handler().postDelayed(new Runnable() 30 | { 31 | @Override 32 | public void run() 33 | { 34 | randomTextView.addKeyWord("彭丽媛"); 35 | randomTextView.addKeyWord("习近平"); 36 | randomTextView.show(); 37 | } 38 | }, 2 * 1000); 39 | ``` 40 | 41 | ## 添加动态发现水波效果 42 | ![image](https://github.com/gpfduoduo/RadarScanView/blob/master/RadarScanView/gif/radarscan.gif "效果图") 43 | 44 | 45 | -------------------------------------------------------------------------------- /RadarScanView/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /RadarScanView/.idea/.name: -------------------------------------------------------------------------------- 1 | RadarScanView -------------------------------------------------------------------------------- /RadarScanView/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /RadarScanView/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /RadarScanView/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /RadarScanView/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 22 | -------------------------------------------------------------------------------- /RadarScanView/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 26 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 58 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /RadarScanView/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /RadarScanView/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /RadarScanView/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /RadarScanView/RadarScanView.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /RadarScanView/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /RadarScanView/app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 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 | -------------------------------------------------------------------------------- /RadarScanView/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.0" 6 | 7 | defaultConfig { 8 | applicationId "com.guo.duoduo.radarscanview" 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 project(':library') 26 | compile project(':randomtextview') 27 | compile 'com.android.support:appcompat-v7:23.1.0' 28 | compile 'com.android.support:design:23.1.0' 29 | } 30 | -------------------------------------------------------------------------------- /RadarScanView/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:\developtools\android sdk windows/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 | -------------------------------------------------------------------------------- /RadarScanView/app/src/androidTest/java/com/guo/duoduo/radarscanview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.guo.duoduo.radarscanview; 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 | } -------------------------------------------------------------------------------- /RadarScanView/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/java/com/guo/duoduo/radarscanview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.guo.duoduo.radarscanview; 2 | 3 | 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | import android.view.View; 11 | 12 | import com.guo.duoduo.randomtextview.RandomTextView; 13 | 14 | 15 | public class MainActivity extends AppCompatActivity 16 | { 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) 20 | { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | 24 | final RandomTextView randomTextView = (RandomTextView) findViewById( 25 | R.id.random_textview); 26 | randomTextView.setOnRippleViewClickListener( 27 | new RandomTextView.OnRippleViewClickListener() 28 | { 29 | @Override 30 | public void onRippleViewClicked(View view) 31 | { 32 | MainActivity.this.startActivity( 33 | new Intent(MainActivity.this, RefreshProgressActivity.class)); 34 | } 35 | }); 36 | 37 | new Handler().postDelayed(new Runnable() 38 | { 39 | @Override 40 | public void run() 41 | { 42 | randomTextView.addKeyWord("彭丽媛"); 43 | randomTextView.addKeyWord("习近平"); 44 | randomTextView.show(); 45 | } 46 | }, 2 * 1000); 47 | } 48 | 49 | @Override 50 | public boolean onCreateOptionsMenu(Menu menu) 51 | { 52 | getMenuInflater().inflate(R.menu.menu_main, menu); 53 | return true; 54 | } 55 | 56 | @Override 57 | public boolean onOptionsItemSelected(MenuItem item) 58 | { 59 | int id = item.getItemId(); 60 | if (id == R.id.action_settings) 61 | { 62 | return true; 63 | } 64 | return super.onOptionsItemSelected(item); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/java/com/guo/duoduo/radarscanview/RefreshProgressActivity.java: -------------------------------------------------------------------------------- 1 | package com.guo.duoduo.radarscanview; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.Toolbar; 9 | import android.view.View; 10 | 11 | 12 | public class RefreshProgressActivity extends AppCompatActivity 13 | { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) 17 | { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_refresh_progress); 20 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 21 | setSupportActionBar(toolbar); 22 | 23 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 24 | fab.setOnClickListener(new View.OnClickListener() 25 | { 26 | @Override 27 | public void onClick(View view) 28 | { 29 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 30 | .setAction("Action", null).show(); 31 | } 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/layout/activity_refresh_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/layout/content_refresh_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gpfduoduo/RadarScanView/bda53b8b9ca9d4f75e57c346842178773bceeb9c/RadarScanView/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gpfduoduo/RadarScanView/bda53b8b9ca9d4f75e57c346842178773bceeb9c/RadarScanView/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gpfduoduo/RadarScanView/bda53b8b9ca9d4f75e57c346842178773bceeb9c/RadarScanView/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gpfduoduo/RadarScanView/bda53b8b9ca9d4f75e57c346842178773bceeb9c/RadarScanView/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RadarScanView 3 | 4 | Hello world! 5 | Settings 6 | RefreshProgressActivity 7 | 8 | -------------------------------------------------------------------------------- /RadarScanView/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 12 | 13 |