here is my code

XML Markup

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/TextLabel">

    <EditText
        android:id="@+id/etContactName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Contact Name"/>

</android.support.design.widget.TextInputLayout>

Style

<style name="TextLabel" parent="TextAppearance.AppCompat">
    <item name="android:textColorHint">@color/hintColor</item>
    <item name="colorAccent">@color/primaryColor</item>
    <item name="colorControlNormal">@color/hintColor</item>
    <item name="colorControlActivated">@color/primaryColor</item>
</style>

Here is the output
(normal view)
Normal View

(focused view)

Focused View

Now My Problems / Issues

  1. I want the bottom line to be thinner. where should I change it.
  2. The blinking cursor is not showing, how to show it.
  3. EditText is automatically highlighting the spelling mistakes. I need to stop it.

Can anyone please point me to the right way to resolve the issues. Comment you anyone needs more info to answer this.

Thanks in advance.

  • How did you resolve this? Could you share with us? – Selin Apr 11 '16 at 7:50
  • @Selin: Posted my solution – Krishanu Dey Apr 11 '16 at 8:30
up vote 36 down vote accepted
+500

I've solved my issue using my custom xml drawable. There might be some better way, but I couldn't find any. following is my drawable that I'm using as background of my textbox

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <layer-list >
            <item
                android:bottom="1dp"
                android:left="-2dp"
                android:right="-2dp"
                android:top="-2dp">
                <shape android:shape="rectangle" >
                    <stroke
                        android:width="0.5dp"
                        android:color="@color/primaryColor" />

                    <solid android:color="#00FFFFFF" />

                    <padding android:left="3dp"
                        android:right="3dp"
                        android:top="3dp"
                        android:bottom="3dp" />
                </shape>
            </item>

        </layer-list>
    </item>
    <item android:state_focused="true">
        <layer-list >
            <item
                android:bottom="1dp"
                android:left="-2dp"
                android:right="-2dp"
                android:top="-2dp">
                <shape android:shape="rectangle" >
                    <stroke
                        android:width="0.5dp"
                        android:color="@color/primaryColor" />

                    <solid android:color="#00FFFFFF" />

                    <padding android:left="3dp"
                        android:right="3dp"
                        android:top="3dp"
                        android:bottom="3dp" />
                </shape>
            </item>

        </layer-list>
    </item>
    <item>
        <layer-list >
            <item
                android:bottom="1dp"
                android:left="-2dp"
                android:right="-2dp"
                android:top="-2dp">
                <shape android:shape="rectangle" >
                    <stroke
                        android:width="0.5dp"
                        android:color="#BCBCBC" />

                    <solid android:color="#00FFFFFF" />

                    <padding android:left="3dp"
                        android:right="3dp"
                        android:top="3dp"
                        android:bottom="3dp" />
                </shape>
            </item>

        </layer-list>
    </item>

</selector>
  • Finally, thanks. This worked for me, after trying like 20 different things mentioned in other posts – cfl May 17 '16 at 7:53
  • Thanks a ton sir. Tried a lot of things but this worked out at the end. – Pavan Jan 12 at 12:28
  • I've tried about 7 different options and this is literally the only one that works as expected in every single scenario. – EpicPandaForce Sep 12 at 23:37

Edittext bottom color

android:backgroundTint="@color/yourcolor"

To disable spellchecker add code in your Edittext xml

android:inputType="textNoSuggestions"

Create an XML file with the name "EditTextStyle.xml" in the drawable folder in your project and write the following code:

<?xml version="1.0" encoding="utf-8" ?>

   <shape xmlns:android="http://schemas.android.com/apk/r..."
   android:thickness="0dp"
   android:shape="rectangle">
  <stroke android:width="3dp"
     android:color="#4799E8"/>
  <corners android:radius="5dp" />
  <gradient
  android:startColor="#C8C8C8"
  android:endColor="#FFFFFF"
  android:type="linear"
  android:angle="270"/>
  </shape>

Now add the following attribute to your EditText:

       <EditText    

        android:background="@drawable/EditTextStyle"/>
  • I'm able to change EditText bottom color, I need to change stroke width thinner. – Krishanu Dey Aug 1 '15 at 6:49
  • see my update answer – sasikumar Aug 1 '15 at 7:02

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.