Click on EditText's drawable right with Espresso

前端 未结 4 642
小鲜肉
小鲜肉 2021-02-10 00:54

How could be possible to click on EditText\'s right drawable (check the screenshot)? I have tried several ways but I always get stuck.

public static Matcher

        
4条回答
  •  旧时难觅i
    2021-02-10 01:41

    I solved it using the Material Component TextInputLayout and TextInputEditText

    In your xml:

     
    
                
    
            
    

    The trick here is to set the app:endIconMode="custom" then add your drawable as u want.

    In java class:

    you can use the setEndIconOnClickListener and do what you want as below:

    tilLocation.setEndIconOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //do click
            }
        });
    

提交回复
热议问题