Skip to content

zoom in/ out button when menu opened or closed #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions library/src/com/capricorn/ArcMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class ArcMenu extends RelativeLayout {
private ArcLayout mArcLayout;

private ImageView mHintView;

ViewGroup controlLayout;

public ArcMenu(Context context) {
super(context);
Expand All @@ -62,14 +64,14 @@ private void init(Context context) {

mArcLayout = (ArcLayout) findViewById(R.id.item_layout);

final ViewGroup controlLayout = (ViewGroup) findViewById(R.id.control_layout);
controlLayout = (ViewGroup) findViewById(R.id.control_layout);
controlLayout.setClickable(true);
controlLayout.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mHintView.startAnimation(createHintSwitchAnimation(mArcLayout.isExpanded()));
controlLayout.startAnimation(createHintSwitchAnimation(mArcLayout.isExpanded()));
mArcLayout.switchState(true);
}

Expand Down Expand Up @@ -140,7 +142,7 @@ public void run() {
}

mArcLayout.invalidate();
mHintView.startAnimation(createHintSwitchAnimation(true));
controlLayout.startAnimation(createHintSwitchAnimation(true));

if (listener != null) {
listener.onClick(viewClicked);
Expand Down Expand Up @@ -180,13 +182,27 @@ private static Animation createItemDisapperAnimation(final long duration, final
}

private static Animation createHintSwitchAnimation(final boolean expanded) {
Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,

AnimationSet set = new AnimationSet(false);
Animation animation;
animation = new RotateAnimation(expanded ? 405 : 0, expanded ? 0 : 405,
Animation.RELATIVE_TO_SELF,
0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setStartOffset(0);
animation.setDuration(100);
animation.setDuration(300);
animation.setInterpolator(new DecelerateInterpolator());
animation.setFillAfter(true);

return animation;
animation.setFillEnabled(true);
set.setFillAfter(true);
set.addAnimation(animation);
animation = new ScaleAnimation(1.0f, expanded ? 1f : 0.8f, 1.0f, expanded ? 1f : 0.8f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
animation.setDuration(300);
animation.setInterpolator(new OvershootInterpolator(0.0f));
animation.setFillAfter(false);
set.addAnimation(animation);

return set;
}
}