PopWindow动画实现底部滑出菜单

public class MainActivity extends Activity implements OnClickListener {private Button open;private View parent;private View popView;private PopupWindow popupWindow;private GridView gv;private String[] names = { "生", "如", "夏", "花", "海", "阔", "天", "空" };private int[] images = { R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher };@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);parent = findViewById(R.id.main);open = (Button) findViewById(R.id.open);open.setOnClickListener(this);initPopupWindow();}/** * 初始化popupWindow */private void initPopupWindow() {popView = getLayoutInflater().inflate(R.layout.popupwindow, null);popupWindow = new PopupWindow(popView,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);popupWindow.setFocusable(true);popupWindow.setBackgroundDrawable(new BitmapDrawable());popupWindow.setOutsideTouchable(true);gv = (GridView) popView.findViewById(R.id.gv);gv.setAdapter(MyAdapter());}/** * 为GridView填充数据 * * @return */private ListAdapter MyAdapter() {List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();for (int i = 0; i < names.length; i++) {Map<String, Object> map = new HashMap<String, Object>();map.put("names", names[i]);map.put("images", images[i]);list.add(map);}SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,R.layout.pop_item, new String[] { "names", "images" },new int[] { R.id.tv, R.id.img });return simpleAdapter;}@Overridepublic void onClick(View v) {//为popWindow添加动画效果popupWindow.setAnimationStyle(R.style.popWindow_animation);// 点击弹出泡泡窗口popupWindow.showAtLocation(parent, Gravity.BOTTOM, 0, 0);}}

,获致幸福的不二法门是珍视你所拥有的、遗忘你所没有的

PopWindow动画实现底部滑出菜单

相关文章:

你感兴趣的文章:

标签云: