EditTexts with links both clickable and editable

前端 未结 2 802
时光说笑
时光说笑 2021-02-10 05:30

I am working with EditText which take WebUrl in input.For that I am using LinkMovementMethod Make links in the EditText clickable.

Problem is that :

2条回答
  •  臣服心动
    2021-02-10 05:38

    check the following code.

    EditText inputText;
    //Edittext is clickable at right side.
    inputText.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                final int DRAWABLE_LEFT = 0;
                final int DRAWABLE_TOP = 1;
                final int DRAWABLE_RIGHT = 2;
                final int DRAWABLE_BOTTOM = 3;
    
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    if (event.getRawX() >= (inputText.getRight() - inputText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                       //write your logic
                        return true;
                    }
                }
                return false;
            }
        });
    

提交回复
热议问题