OnClick / OnTouchListener无法在顶视图上绘制

时间:2015-03-10 16:40:23

标签: android onclicklistener

我有一项服务,可以在手机上绘制视图。 但我无法点击或使用onTouch或onClick Listener触摸此视图。 任何想法为什么这不起作用? 在哪个视图上绑定OnClickListener并不重要..它不起作用。

protected WindowManager mWindowManager;
protected View mQueueStatusView;

@Override
public void onCreate() {
    super.onCreate();
    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    mQueueStatusView = inflater.inflate(R.layout.view_queue_indicator, null);
    mQueueStatusView.setVisibility(View.GONE);

    RelativeLayout rlRoot = (RelativeLayout) mQueueStatusView.findViewById(R.id.rl_root_queue_indicatior_container);
      rlRoot.setOnClickListener(new View.OnClickListener() {
       @Override
        public void onClick(View view) {
            Log.d("OVERLAY", "CLICKED!!!!!!!!!");
        }
    });
    rlRoot.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            Log.d("OVERLAY", "CLICKED!!!!!!!!!");
            return false;
        }
    });
    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
            PixelFormat.TRANSLUCENT);

    params.gravity = Gravity.BOTTOM;
    params.x = 0;
    params.y = 0;


    mWindowManager.addView(mQueueStatusView, params);



}

0 个答案:

没有答案