├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── apple.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jzp
│ │ └── rotate3d
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── jzp
│ │ │ └── rotate3d
│ │ │ └── sample
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-xxhdpi
│ │ ├── btn_drop.png
│ │ ├── btn_hide.png
│ │ ├── btn_hide_blue.png
│ │ ├── btn_shape.xml
│ │ ├── home_bg.png
│ │ ├── ic_account_iphone.png
│ │ ├── ic_password.png
│ │ ├── ic_third_login_qq.png
│ │ ├── ic_third_wechat.png
│ │ ├── ic_third_weibo.png
│ │ ├── ic_username.png
│ │ ├── icon_code.png
│ │ └── icon_iphone.png
│ │ ├── drawable
│ │ └── logo.jpg
│ │ ├── layout
│ │ └── activity_main.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
│ └── test
│ └── java
│ └── com
│ └── jzp
│ └── rotate3d
│ └── sample
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── image
├── image.gif
└── qrcode.png
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jzp
│ │ └── rotate3d
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── jzp
│ │ │ └── rotate3d
│ │ │ ├── Rotate3D.java
│ │ │ └── Rotate3dAnimation.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── jzp
│ └── rotate3d
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/apple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | Android
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 | 1.8
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Rotate3D
2 | This is a 3D ratate library ,You can easy use it
3 |
4 | # Preview
5 |
6 | 
7 |
8 | # Demo Apk
9 |
10 | you can scan the qrcode for download demo apk
11 |
12 | 
13 |
14 | # Feature
15 | - Light
16 | - Noninvasive,You don't need to make changes to existing code.
17 | - Wide applicability,It is available for all views
18 |
19 | # Getting started
20 |
21 | In your build.gradle:
22 |
23 | dependencies {
24 | compile 'com.jzp:rotate3D:1.0.0'
25 | }
26 |
27 |
28 | # Usage
29 | create Rotate3D
30 |
31 | Rotate3D anim = new Rotate3D.Builder(this)
32 | .bindParentView(parent_ll)
33 | .bindPositiveView(account_login_ll)
34 | .bindNegativeView(account_phone_ll)
35 | .create();
36 |
37 | start the 3D animation
38 |
39 | anim.transform();
40 | # Follow Me
41 | 
42 |
43 | # License
44 |
45 | Copyright 2017, Rotate3D , 1179537855@qq.com
46 |
47 | Licensed under the Apache License, Version 2.0 (the "License");
48 | you may not use this file except in compliance with the License.
49 | You may obtain a copy of the License at
50 |
51 | http://www.apache.org/licenses/LICENSE-2.0
52 |
53 | Unless required by applicable law or agreed to in writing, software
54 | distributed under the License is distributed on an "AS IS" BASIS,
55 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56 | See the License for the specific language governing permissions and
57 | limitations under the License.
58 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 | defaultConfig {
7 | applicationId "com.jzp.rotate3d.sample"
8 | minSdkVersion 14
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.3.1'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | compile project(":library")
31 | }
32 |
--------------------------------------------------------------------------------
/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 /Users/apple/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/jzp/rotate3d/sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.jzp.rotate3d.sample;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.jzp.rotate3d.sample", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jzp/rotate3d/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.jzp.rotate3d.sample;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.LinearLayout;
7 | import android.widget.TextView;
8 |
9 | import com.jzp.rotate3d.Rotate3D;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | Rotate3D anim;
14 | private LinearLayout account_login_ll;
15 | private LinearLayout account_phone_ll;
16 | private LinearLayout parent_ll;
17 | private TextView no_pass_login;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | account_phone_ll = (LinearLayout) findViewById(R.id.account_phone_ll);
24 | account_login_ll = (LinearLayout) findViewById(R.id.account_login_ll);
25 | parent_ll = (LinearLayout) findViewById(R.id.parent_ll);
26 | no_pass_login = (TextView) findViewById(R.id.no_pass_login);
27 |
28 | anim = new Rotate3D.Builder(this)
29 | .bindParentView(parent_ll)
30 | .bindPositiveView(account_login_ll)
31 | .bindNegativeView(account_phone_ll)
32 | .create();
33 |
34 | no_pass_login.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | anim.transform();
38 | if (anim.isOpen()) {
39 | no_pass_login.setText("使用免密登录");
40 | } else {
41 | no_pass_login.setText("使用账户登录");
42 | }
43 | }
44 | });
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/btn_drop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/btn_drop.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/btn_hide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/btn_hide.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/btn_hide_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/btn_hide_blue.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/btn_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/home_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/home_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_account_iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/ic_account_iphone.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_password.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/ic_password.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_third_login_qq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/ic_third_login_qq.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_third_wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/ic_third_wechat.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_third_weibo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/ic_third_weibo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_username.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/ic_username.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/icon_code.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable-xxhdpi/icon_iphone.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/drawable/logo.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
25 |
26 |
27 |
28 |
35 |
36 |
43 |
51 |
52 |
61 |
62 |
69 |
70 |
83 |
84 |
93 |
94 |
95 |
103 |
104 |
110 |
111 |
118 |
119 |
132 |
133 |
140 |
141 |
142 |
143 |
151 |
152 |
153 |
160 |
161 |
169 |
170 |
180 |
181 |
187 |
188 |
195 |
196 |
209 |
210 |
219 |
220 |
221 |
229 |
230 |
236 |
237 |
243 |
244 |
257 |
258 |
265 |
266 |
274 |
275 |
276 |
277 |
285 |
286 |
287 |
288 |
302 |
303 |
304 |
305 |
315 |
316 |
322 |
323 |
329 |
330 |
342 |
343 |
347 |
348 |
360 |
361 |
362 |
363 |
368 |
369 |
375 |
376 |
383 |
384 |
391 |
392 |
399 |
400 |
401 |
402 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #e2e2e2
7 | #0366c1
8 | #000000
9 | #ffffffff
10 | #999999
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Rotate3DSample
3 | 输入手机号码/邮箱/用户名
4 | 请输入登录密码
5 | 请输入手机号码
6 | 请输入验证码
7 | 登录
8 | 忘记密码
9 | 立即注册
10 | 第三方登录
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/jzp/rotate3d/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.jzp.rotate3d.sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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.3.3'
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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Aug 31 16:19:33 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/image/image.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/image/image.gif
--------------------------------------------------------------------------------
/image/qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangzepeng/Rotate3DSample/fd5075db3d1a1aa3214582440de774507a7e2fc5/image/qrcode.png
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'//添加
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.3"
7 |
8 | defaultConfig {
9 | minSdkVersion 14
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 | //添加
25 | publish {
26 | userOrg = 'jzplibrary'//bintray.com自己创建的组织名称
27 | groupId = 'com.jzp'//项目路径
28 | artifactId = 'rotate3D'//项目名称
29 | publishVersion = '1.0.0'//版本号
30 | desc = 'Oh hi, this is a nice description for a project, right?'//描述,不重要,随便写
31 | website = 'https://github.com/jiangzepeng/MyModel'//随便写;当然有github地址最好了
32 | }
33 | dependencies {
34 | compile fileTree(dir: 'libs', include: ['*.jar'])
35 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
36 | exclude group: 'com.android.support', module: 'support-annotations'
37 | })
38 | compile 'com.android.support:appcompat-v7:25.3.1'
39 | testCompile 'junit:junit:4.12'
40 | }
41 |
--------------------------------------------------------------------------------
/library/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 /Users/apple/Library/Android/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/jzp/rotate3d/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.jzp.rotate3d;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.jzp.rotate3d.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/library/src/main/java/com/jzp/rotate3d/Rotate3D.java:
--------------------------------------------------------------------------------
1 | package com.jzp.rotate3d;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.animation.AccelerateInterpolator;
6 | import android.view.animation.Animation;
7 | import android.view.animation.DecelerateInterpolator;
8 |
9 | /**
10 | * Description : 旋转3D动画
11 | * Author : jzp
12 | * Date : 17/8/31
13 | */
14 |
15 | public class Rotate3D {
16 | private Context context;
17 | private View parentView;
18 | private View positiveView;
19 | private View negativeView;
20 |
21 | private int centerX;
22 | private int centerY;
23 | private int depthZ;
24 | private int duration;
25 | private Rotate3dAnimation openAnimation;
26 | private Rotate3dAnimation closeAnimation;
27 |
28 | private boolean isOpen = false;
29 |
30 | private Rotate3D(Builder builder) {
31 | this.context = builder.context;
32 | this.parentView = builder.parentView;
33 | this.positiveView = builder.positiveView;
34 | this.negativeView = builder.negativeView;
35 | this.duration = builder.duration;
36 | this.depthZ = builder.depthZ;
37 | }
38 |
39 | public View getParentView() {
40 | return parentView;
41 | }
42 |
43 | public View getPositiveView() {
44 | return positiveView;
45 | }
46 |
47 | public View getNegativeView() {
48 | return negativeView;
49 | }
50 |
51 | public void transform() {
52 | //以旋转对象的中心点为旋转中心点,这里主要不要再onCreate方法中获取,因为视图初始绘制时,获取的宽高为0
53 | centerX = parentView.getWidth() / 2;
54 | centerY = parentView.getHeight() / 2;
55 | if (openAnimation == null) {
56 | initOpenAnim();
57 | initCloseAnim();
58 | }
59 |
60 | //用作判断当前点击事件发生时动画是否正在执行
61 | if (openAnimation.hasStarted() && !openAnimation.hasEnded()) {
62 | return;
63 | }
64 | if (closeAnimation.hasStarted() && !closeAnimation.hasEnded()) {
65 | return;
66 | }
67 |
68 | //判断动画执行
69 | parentView.startAnimation(isOpen ? closeAnimation : openAnimation);
70 |
71 | isOpen = !isOpen;
72 | }
73 |
74 | public boolean isOpen() {
75 | return isOpen;
76 | }
77 |
78 | /**
79 | * 卡牌文本介绍打开效果:注意旋转角度
80 | */
81 | private void initOpenAnim() {
82 | //从0到90度,顺时针旋转视图,此时reverse参数为true,达到90度时动画结束时视图变得不可见,
83 | openAnimation = new Rotate3dAnimation(context, 0, 90, centerX, centerY, depthZ, true);
84 | openAnimation.setDuration(duration);
85 | openAnimation.setFillAfter(true);
86 | openAnimation.setInterpolator(new AccelerateInterpolator());
87 | openAnimation.setAnimationListener(new Animation.AnimationListener() {
88 |
89 | @Override
90 | public void onAnimationStart(Animation animation) {
91 |
92 | }
93 |
94 | @Override
95 | public void onAnimationRepeat(Animation animation) {
96 |
97 | }
98 |
99 | @Override
100 | public void onAnimationEnd(Animation animation) {
101 | positiveView.setVisibility(View.GONE);
102 | negativeView.setVisibility(View.VISIBLE);
103 |
104 | //从270到360度,顺时针旋转视图,此时reverse参数为false,达到360度动画结束时视图变得可见
105 | Rotate3dAnimation rotateAnimation = new Rotate3dAnimation(context, 270, 360, centerX, centerY, depthZ, false);
106 | rotateAnimation.setDuration(duration);
107 | rotateAnimation.setFillAfter(true);
108 | rotateAnimation.setInterpolator(new DecelerateInterpolator());
109 | parentView.startAnimation(rotateAnimation);
110 | }
111 | });
112 | }
113 |
114 | /**
115 | * 卡牌文本介绍关闭效果:旋转角度与打开时逆行即可
116 | */
117 | private void initCloseAnim() {
118 | closeAnimation = new Rotate3dAnimation(context, 360, 270, centerX, centerY, depthZ, true);
119 | closeAnimation.setDuration(duration);
120 | closeAnimation.setFillAfter(true);
121 | closeAnimation.setInterpolator(new AccelerateInterpolator());
122 | closeAnimation.setAnimationListener(new Animation.AnimationListener() {
123 |
124 | @Override
125 | public void onAnimationStart(Animation animation) {
126 |
127 | }
128 |
129 | @Override
130 | public void onAnimationRepeat(Animation animation) {
131 |
132 | }
133 |
134 | @Override
135 | public void onAnimationEnd(Animation animation) {
136 | positiveView.setVisibility(View.VISIBLE);
137 | negativeView.setVisibility(View.GONE);
138 |
139 | Rotate3dAnimation rotateAnimation = new Rotate3dAnimation(context, 90, 0, centerX, centerY, depthZ, false);
140 | rotateAnimation.setDuration(duration);
141 | rotateAnimation.setFillAfter(true);
142 | rotateAnimation.setInterpolator(new DecelerateInterpolator());
143 | parentView.startAnimation(rotateAnimation);
144 | }
145 | });
146 | }
147 |
148 | public static class Builder {
149 | private int depthZ = 400;
150 | private int duration = 400;
151 | private Context context;
152 | private View parentView;
153 | private View positiveView;
154 | private View negativeView;
155 |
156 | public Builder(Context context) {
157 | this.context = context;
158 | }
159 |
160 | public Builder setDepthZ(int depthZ) {
161 | this.depthZ = depthZ;
162 | return this;
163 | }
164 |
165 | public Builder bindParentView(View parentView) {
166 | this.parentView = parentView;
167 | return this;
168 | }
169 |
170 | public Builder bindPositiveView(View positiveView) {
171 | this.positiveView = positiveView;
172 | return this;
173 | }
174 |
175 | public Builder bindNegativeView(View negativeView) {
176 | this.negativeView = negativeView;
177 | return this;
178 | }
179 |
180 | public Builder setDuration(int duration) {
181 | this.duration = duration;
182 | return this;
183 | }
184 |
185 | public Rotate3D create() {
186 | Rotate3D rotate3D = new Rotate3D(this);
187 | if (rotate3D.getParentView() == null) {
188 | throw new NullPointerException("Please set ParentView");
189 | }
190 | if (rotate3D.getPositiveView() == null) {
191 | throw new NullPointerException("Please set PositiveView");
192 | }
193 | if (rotate3D.getNegativeView() == null) {
194 | throw new NullPointerException("Please set NegativeView");
195 | }
196 |
197 | return rotate3D;
198 | }
199 | }
200 |
201 | }
202 |
--------------------------------------------------------------------------------
/library/src/main/java/com/jzp/rotate3d/Rotate3dAnimation.java:
--------------------------------------------------------------------------------
1 | package com.jzp.rotate3d;
2 |
3 | import android.content.Context;
4 | import android.graphics.Camera;
5 | import android.graphics.Matrix;
6 | import android.view.animation.Animation;
7 | import android.view.animation.Transformation;
8 |
9 | /**
10 | * Description :
11 | * Author : jzp
12 | * Date : 17/8/30
13 | */
14 |
15 | public class Rotate3dAnimation extends Animation {
16 | private final float mFromDegrees;
17 | private final float mToDegrees;
18 | private final float mCenterX;
19 | private final float mCenterY;
20 | private final float mDepthZ;
21 | private final boolean mReverse;
22 | private Camera mCamera;
23 | float scale = 1; // 像素密度
24 |
25 | /**
26 | * 创建一个绕 y 轴旋转的3D动画效果,旋转过程中具有深度调节,可以指定旋转中心。
27 | *
28 | * @param context 上下文,用于获取像素密度
29 | * @param fromDegrees 起始时角度
30 | * @param toDegrees 结束时角度
31 | * @param centerX 旋转中心x坐标
32 | * @param centerY 旋转中心y坐标
33 | * @param depthZ 最远到达的z轴坐标
34 | * @param reverse true 表示由从0到depthZ,false相反
35 | */
36 |
37 | public Rotate3dAnimation(Context context, float fromDegrees, float toDegrees,
38 | float centerX, float centerY, float depthZ, boolean reverse) {
39 | mFromDegrees = fromDegrees;
40 | mToDegrees = toDegrees;
41 | mCenterX = centerX;
42 | mCenterY = centerY;
43 | mDepthZ = depthZ;
44 | mReverse = reverse;
45 | // 获取手机像素密度 (即dp与px的比例)
46 | scale = context.getResources().getDisplayMetrics().density;
47 | }
48 |
49 | @Override
50 | public void initialize(int width, int height, int parentWidth, int parentHeight) {
51 | super.initialize(width, height, parentWidth, parentHeight);
52 | mCamera = new Camera();
53 | }
54 |
55 | @Override
56 | protected void applyTransformation(float interpolatedTime, Transformation t) {
57 | final float fromDegrees = mFromDegrees;
58 | float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
59 |
60 | final float centerX = mCenterX;
61 | final float centerY = mCenterY;
62 | final Camera camera = mCamera;
63 | final Matrix matrix = t.getMatrix();
64 |
65 | camera.save();
66 | // 调节深度
67 | if (mReverse) {
68 | camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
69 | } else {
70 | camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
71 | }
72 | // 绕y轴旋转
73 | camera.rotateY(degrees);
74 | camera.getMatrix(matrix);
75 | camera.restore();
76 |
77 | // 修正失真
78 | float[] mValues = new float[9];
79 | matrix.getValues(mValues); //获取数值
80 | mValues[6] = mValues[6] / scale; //数值修正
81 | mValues[7] = mValues[7] / scale; //数值修正
82 | matrix.setValues(mValues); //重新赋值
83 |
84 | // 调节中心点,旋转中心默认是坐标原点,对于图片来说就是左上角位置。
85 | matrix.preTranslate(-centerX, -centerY); // 使用pre将旋转中心移动到和Camera位置相同
86 | matrix.postTranslate(centerX, centerY); // 使用post将图片(View)移动到原来的位置
87 | }
88 | }
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/test/java/com/jzp/rotate3d/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.jzp.rotate3d;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------