android PopupWindow

来源:互联网 发布:游戏耳机推荐知乎 编辑:程序博客网 时间:2024/05/22 05:17

public void setPopManu() {
  View layout = LayoutInflater.from(getApplicationContext()).inflate(
    R.layout.setting_menu, null);
  TextView time_set = (TextView) layout.findViewById(R.id.time_set);
  TextView comment_set = (TextView) layout.findViewById(R.id.comment_set);
  TextView followerPaly = (TextView) layout
    .findViewById(R.id.follower_play_set);
  final PopupWindow menuWindow = new PopupWindow(layout,
    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // 后两个参数是width和height
  menuWindow.setOutsideTouchable(true);
  menuWindow.setFocusable(true);
  // ColorDrawable dw = new ColorDrawable(-00000);
  menuWindow.setBackgroundDrawable(new ColorDrawable(-00000)); //设置了
setBackgroundDrawable可以点击PopupWindow 外边取消
  menuWindow.setTouchable(true); // 设置PopupWindow可触摸
  menuWindow.setContentView(layout);
  menuWindow.showAtLocation(menu, Gravity.RIGHT | Gravity.BOTTOM, 0, 60);//这里的menu是以那个view为基准点的,最好是点那个view弹起PopupWindow 为基准
 }
0 0