I'm trying to make my disabled EditText's style like in guidelines:
https://www.google.com/design/spec/components/text-fields.html#text-fields-labels
<EditText
android:id="@+id/account_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/test_account"
android:enabled="false" />
I've already implemented material design styles, so all my widgets look material.
The question is: Is there any way to get this dotted underline using styles, without putting additional views?
My styles.xml
:
<style name="Theme.Main" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:editTextStyle">@style/android:Widget.Material.EditText</item>
</style>
Finally I ended up with a custom view. It might be not the most elegant solution but it solves my task.
Hope it will be helpful for someone.
DisabledTextField.java:
/layout/component_disabled_text.xml:
/values/attributes_disabled_text_field.xml:
/drawable/disabled_text_field_background.xml:
/values/styles.xml:
Example of usage:
And the result:
Finally I managed to do as you've shown, It looks like
Create
dotted.xml
insidedrawable
folder and paste theseThen simply set the
android:background
attribute todotted.xml
we just created. YourEditText
looks like this.AFAIK, there is no "stock" way. Take the material design guidelines as it is, a guideline ;)