├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── dragview.jks ├── proguard-rules.pro ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── sonnyjack │ │ │ └── drawview │ │ │ └── MainActivity.java │ │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml └── 密码.txt ├── build.gradle ├── device-2018-01-21-212602.mp4 ├── device-2018-06-13-215330.png ├── device-2018-06-13-215423.png ├── device-2018-06-13-215444.png ├── gradle.properties ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── sonnyjack │ │ └── widget │ │ └── dragview │ │ └── SonnyJackDragView.java │ └── res │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /gradle 8 | /captures 9 | .externalNativeBuild 10 | gradlew 11 | gradlew.bat 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #使用方式 2 | implementation 'com.sonnyjack.widget:DragView:0.1.0' 3 | 4 | 或 5 | 6 | api 'com.sonnyjack.widget:DragView:0.1.0' 7 | 8 | 备注:由于之前的命名有误,DrawView改为DragView 9 | 10 | 用法如下: 11 | 12 | ImageView imageView = new ImageView(this); 13 | imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); 14 | imageView.setImageResource(R.mipmap.ic_launcher_round); 15 | imageView.setOnClickListener(v -> Toast.makeText(MainActivity.this, "点击了...", Toast.LENGTH_SHORT).show()); 16 | 17 | SonnyJackDragView sonnyJackDragView = new SonnyJackDragView.Builder() 18 | .setActivity(this)//当前Activity,不可为空 19 | .setDefaultLeft(30)//初始位置左边距 20 | .setDefaultTop(30)//初始位置上边距 21 | .setNeedNearEdge(false)//拖动停止后,是否移到边沿 22 | .setSize(100)//DragView大小 23 | .setView(imageView)//设置自定义的DragView,切记不可为空 24 | .build(); 25 | 26 | 也可手动设置拖动停止后,是否移到边沿 27 | 28 | boolean needNearEdge = sonnyJackDragView.getNeedNearEdge(); 29 | sonnyJackDragView.setNeedNearEdge(!needNearEdge); 30 | 31 | 效果如图: 32 | 33 | 34 |
35 | 36 | 37 | 38 |
39 | 40 | 如果遇到什么问题可以加我Q:252624617 或者issues反馈 41 | 42 | 不知道如何显示mp4,可自行下载device-2018-01-21-212602.mp4文件查看 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.sonnyjack.drawview" 7 | minSdkVersion 14 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | } 12 | //签名 13 | signingConfigs { 14 | release { 15 | storeFile file("dragview.jks") 16 | storePassword "123456" 17 | keyAlias "SonnyJack" 18 | keyPassword "123456" 19 | } 20 | debug { 21 | storeFile file("dragview.jks") 22 | storePassword "123456" 23 | keyAlias "SonnyJack" 24 | keyPassword "123456" 25 | } 26 | } 27 | buildTypes { 28 | debug { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | signingConfig signingConfigs.debug 32 | } 33 | 34 | release { 35 | minifyEnabled false 36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 37 | signingConfig signingConfigs.release 38 | } 39 | } 40 | compileOptions { 41 | //支持java8特性 42 | sourceCompatibility JavaVersion.VERSION_1_8 43 | targetCompatibility JavaVersion.VERSION_1_8 44 | } 45 | } 46 | 47 | dependencies { 48 | implementation fileTree(include: ['*.jar'], dir: 'libs') 49 | implementation project(path: ':library') 50 | implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' 51 | } 52 | -------------------------------------------------------------------------------- /app/dragview.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linqssonny/DragView/34e62100893bbb0440bdffc3fe84c08e2db13153/app/dragview.jks -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/sonnyjack/drawview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sonnyjack.drawview; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.ImageView; 8 | import android.widget.Toast; 9 | 10 | import com.sonnyjack.widget.dragview.SonnyJackDragView; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | private SonnyJackDragView mSonnyJackDragView; 15 | private Button mButton; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | 22 | mButton = findViewById(R.id.btn_move); 23 | mButton.setOnClickListener(v -> { 24 | boolean needNearEdge = mSonnyJackDragView.getNeedNearEdge(); 25 | mSonnyJackDragView.setNeedNearEdge(!needNearEdge); 26 | if (needNearEdge) { 27 | mButton.setText("移至边沿"); 28 | } else { 29 | mButton.setText("固定位置"); 30 | } 31 | }); 32 | ImageView imageView = new ImageView(this); 33 | imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); 34 | imageView.setImageResource(R.mipmap.ic_launcher_round); 35 | imageView.setOnClickListener(v -> Toast.makeText(MainActivity.this, "点击了...", Toast.LENGTH_SHORT).show()); 36 | 37 | mSonnyJackDragView = new SonnyJackDragView.Builder() 38 | .setActivity(this) 39 | .setDefaultLeft(30) 40 | .setDefaultTop(30) 41 | .setNeedNearEdge(false) 42 | .setSize(100) 43 | .setView(imageView) 44 | .build(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |