本实例的自定义下拉菜单主要是继承PopupWindow类来实现的弹出窗体,各种布局效果可以根据自己定义设计。弹出的动画效果主要用到了translate、alpha、scale,具体实现步骤如下:
先上效果图如下:左边下拉菜单、中间下拉菜单、右边下拉菜单
1.主界面布局 activity_main.xml:
[html] view plain copy
2.主界面测试类 MainActivity.java
[java] view plain copy
3.自定义弹窗类 TopMiddlePopup.java
[java] view plain copy
4.自定义弹窗布局 top_popup.xml
[html] view plain copy
5.弹窗类表适配器类 PopupAdapter
[java] view plain copy
6.子item布局 top_popup_item.xml
[html] view plain copy
7.主界面顶部布局 urm_top.xml
[html] view plain copy
8.styles.xml文件
[html] view plain copy
9.各种动画效果
push_top_in.xml
[html] view plain copy
push_top_out.xml
[html] view plain copy
top_left_in.xml
[html] view plain copy
top_left_out.xml
[html] view plain copy
top_middle_in.xml
[html] view plain copy
top_middle_out.xml
[html] view plain copy
top_right_in.xml
[html] view plain copy
top_right_out.xml
[html] view plain copy
运行项目即可搞定!