Skip to content

Commit 237ccbb

Browse files
committed
Merge pull request #67 from LivioGama/master
Added 3D support
2 parents 70d46c2 + 0a258a7 commit 237ccbb

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

3Dsupport.png

988 KB
Loading

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ And thanks to the authors for the above idea and contribution.
88
<img src="https://github.com/SpecialCyCi/AndroidResideMenu/raw/master/1.png" width="320" height="568" />
99
<img src="https://github.com/SpecialCyCi/AndroidResideMenu/raw/master/2.gif" width="320" height="568" />
1010

11+
Now with 3D support !
12+
<img src="https://github.com/SpecialCyCi/AndroidResideMenu/raw/master/3Dsupport.png" width="320" height="568" />
1113
## DEMO
1214
This copy is the demo.
1315

ResideMenu/src/com/special/ResideMenu/ResideMenu.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public class ResideMenu extends FrameLayout{
6464
// Valid scale factor is between 0.0f and 1.0f.
6565
private float mScaleValue = 0.5f;
6666

67+
private boolean mUse3D;
68+
private static final int ROTATE_Y_ANGLE = 10;
69+
6770
public ResideMenu(Context context) {
6871
super(context);
6972
initViews(context);
@@ -386,6 +389,11 @@ private AnimatorSet buildScaleDownAnimation(View target,float targetScaleX,float
386389
ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
387390
);
388391

392+
if (mUse3D) {
393+
int angle = scaleDirection == DIRECTION_LEFT ? -ROTATE_Y_ANGLE : ROTATE_Y_ANGLE;
394+
scaleDown.playTogether(ObjectAnimator.ofFloat(target, "rotationY", angle));
395+
}
396+
389397
scaleDown.setInterpolator(AnimationUtils.loadInterpolator(activity,
390398
android.R.anim.decelerate_interpolator));
391399
scaleDown.setDuration(250);
@@ -408,6 +416,10 @@ private AnimatorSet buildScaleUpAnimation(View target,float targetScaleX,float t
408416
ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
409417
);
410418

419+
if (mUse3D) {
420+
scaleUp.playTogether(ObjectAnimator.ofFloat(target, "rotationY", 0));
421+
}
422+
411423
scaleUp.setDuration(250);
412424
return scaleUp;
413425
}
@@ -576,6 +588,10 @@ public void setScaleValue(float scaleValue) {
576588
this.mScaleValue = scaleValue;
577589
}
578590

591+
public void setUse3D(boolean use3D) {
592+
mUse3D = use3D;
593+
}
594+
579595
public interface OnMenuListener{
580596

581597
/**

ResideMenuDemo/src/com/special/ResideMenuDemo/MenuActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private void setUpMenu() {
3636

3737
// attach to current activity;
3838
resideMenu = new ResideMenu(this);
39+
resideMenu.setUse3D(true);
3940
resideMenu.setBackground(R.drawable.menu_background);
4041
resideMenu.attachToActivity(this);
4142
resideMenu.setMenuListener(menuListener);

0 commit comments

Comments
 (0)