Create a drawable underline.xml
in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@android:color/black"
android:dashGap="3.0dp"
android:dashWidth="1dp" />
</shape>
</item>
and then programatically apply this drawable and set it as disabled
editText=(EditText)findViewById(R.id.your_edittext);
editText.setEnabled(false);
editText.setBackgroundResource(R.drawable.underline);
Output :
