Please follow below steps to accomplish the show/hide functionality on EditText Add EditText to your text file <EditText android :id= "@+id/password" android :layout_width= "wrap_content" android :layout_height= "wrap_content" android :inputType= "textPassword" android :ems= "10" android :drawableRight= "@drawable/eye" android :layout_centerHorizontal= "true" /> Add OnTouchListener for EditText editText = findViewById(R.id. password ) ; editText .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_DOWN ) { if (event.getRawX() >= ( editText .getRigh...
Please follow below steps to accomplish toggle button like iOS using xml only. Step 1: Add switch control on your layout file. <Switch android :id= "@+id/mySwitch" android :layout_width= "wrap_content" android :layout_height= "wrap_content" android :thumb= "@drawable/selector " android :track= "@drawable/track" /> Step 2 : Create selector.xml in drawable folder <? xml version= "1.0" encoding= "utf-8" ?> <selector xmlns: android = "http://schemas.android.com/apk/res/android" > <item android :state_enabled= "false" > <shape android :shape= "oval" > <solid android :color= "#838282" /> <stroke android :width= "@dimen/switch_stroke_width" android :color= "#69696...