forked from razerdp/BasePopup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuPopup.java
83 lines (69 loc) · 2.4 KB
/
MenuPopup.java
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
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
package razerdp.demo.popup;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.widget.TextView;
import razerdp.basepopup.BasePopupWindow;
import razerdp.basepopup.R;
import razerdp.demo.utils.ToastUtils;
/**
* Created by 大灯泡 on 2016/1/22.
* 菜单。
*/
public class MenuPopup extends BasePopupWindow implements View.OnClickListener {
private TextView tx1;
private TextView tx2;
private TextView tx3;
public MenuPopup(Context context) {
super(context);
findViewById(R.id.tx_1).setOnClickListener(this);
findViewById(R.id.tx_2).setOnClickListener(this);
findViewById(R.id.tx_3).setOnClickListener(this);
setAlignBackground(false);
setPopupGravity(Gravity.BOTTOM | Gravity.LEFT);
}
@Override
protected Animation onCreateShowAnimation() {
AnimationSet set = new AnimationSet(true);
set.setInterpolator(new DecelerateInterpolator());
set.addAnimation(getScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0));
set.addAnimation(getDefaultAlphaAnimation());
return set;
}
@Override
protected Animation onCreateDismissAnimation() {
AnimationSet set = new AnimationSet(true);
set.setInterpolator(new DecelerateInterpolator());
set.addAnimation(getScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0));
set.addAnimation(getDefaultAlphaAnimation(false));
return set;
}
@Override
public void showPopupWindow(View v) {
setOffsetX(v.getWidth() / 2);
super.showPopupWindow(v);
}
@Override
public View onCreateContentView() {
return createPopupById(R.layout.popup_menu);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tx_1:
ToastUtils.ToastMessage(getContext(), "click tx_1");
break;
case R.id.tx_2:
ToastUtils.ToastMessage(getContext(), "click tx_2");
break;
case R.id.tx_3:
ToastUtils.ToastMessage(getContext(), "click tx_3");
break;
default:
break;
}
}
}