Reputation: 811
Let's say I have a edittext input for date of birth:
I want to dynamically change its state to then be disabled, and for it to have a dotted underline to show that it's disabled:
How would I go about doing that? It would be according to the google material design guidelines:
Upvotes: 1
Views: 395
Reputation: 5017
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 :
Upvotes: 1