Get parent texInputlayout from child textInputEditText

Instead of using TextInputLayout textInputLayout = (TextInputLayout) findViewById(v.getId()).getParent(); use the instance of view like TextInputEditText et = (TextInputEditText) v;and then TextInputLayout lay = (TextInputLayout)et.getParent().getParent();


I solved the problem with the below line of code:

TextInputLayout textInputLayout = (TextInputLayout) findViewById(v.getId()).getParent().getParent();

It returns textInputlayout as required.