如何减少android中弹出窗口的延迟?

时间:2015-10-16 05:12:22

标签: android canvas popup popupwindow

This program output picture

你们都看到上面的图片并运行以下代码。

public class NewClass extends View{

    float initialX,initialY;
    View view;
    Paint paint;
    TextView txtView;
    PopupWindow pop;
    public NewClass(Context context)
    {
        super(context);
        paint=new Paint();
        view=new View(context);

        txtView = new TextView(getContext());
        pop = new PopupWindow(getContext());

        txtView.setTextSize(10);
        txtView.setText("sss");
        txtView.setTypeface(null, Typeface.BOLD);
        txtView.setGravity(Gravity.CENTER);
        txtView.setBackgroundColor(Color.MAGENTA);

        pop.setContentView(txtView);
        pop.setHeight(20);
        pop.setWidth(40);
        OnTouchChild();

    }

    public void OnTouchChild() {

        this.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                switch (event.getAction() & MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_DOWN:
                        initialX = event.getX();
                        initialY = event.getY();

                        if (pop.isShowing()) {
                            pop.dismiss();
                        }
                String s=String.valueOf(initialX);
                txtView.setText(s);

                        pop.showAsDropDown(view,100,100,Gravity.CENTER);

                        break;

                    case MotionEvent.ACTION_MOVE:
                        initialX = event.getX();
                        initialY = event.getY();

                        if (pop.isShowing())
                            pop.dismiss();

                        String s1=String.valueOf(initialX);

                        txtView.setText(s1);

                        pop.showAsDropDown(view,100,100,Gravity.CENTER);
                }
                return true;
            }
        });
    }
}

您同时使用上述编码的操作向下和操作移动选项。

我的问题是如何减少显示弹出窗口的延迟?

请所有人都知道回答我。!

0 个答案:

没有答案