解决方案 »

  1.   

    可以将上下两个菜单栏的布局分别写两个布局文件,然后在onTouch中 用PopupWindow来显示
    比如:
                   //假如上面的菜单栏
                    LayoutInflater      mInflater = LayoutInflater.from(context);
                  //layout.del_btn就是你上面的菜单布局文件
    View view = mInflater.inflate(R.layout.del_btn, null);
                 //菜单布局文件的控件,这里假设有两个按钮
    bt1 = (Button) view.findViewById(R.id.id_item_btn);
    bt2 = (Button) view.findViewById(R.id.id_item_btn1);
    popupWindow = new PopupWindow(view,
    LinearLayout.LayoutParams.WRAP_CONTENT,
    LinearLayout.LayoutParams.WRAP_CONTENT);
    popupWindow.getContentView().measure(0, 0);
                    //PopupWindow高
    pop_h = popupWindow.getContentView().getMeasuredHeight();
                   //PopupWindow宽
    pop_w = popupWindow.getContentView().getMeasuredWidth();上面定义好后,你在点击屏幕或点击MENU键时,调用下面的方法:
                        / /这边动画可有可无
                         popupWindow.setAnimationStyle(R.style.popwindow_delete_ben_anim_style);
    popupWindow.update();
                                     //显示的位置,这里面的参数由你来定
    popupWindow.showAtLocation();
                                        /  /菜单项事件
    bt1.setOnClickListener(new OnClickListener() {};
                                    bt1.setOnClickListener(new OnClickListener() {};