Question

I'm trying to change the color or disable the highlight of the text when writing on my EditText.

  • How can I do that?
  • How can I set rounded borders to the highlight?

I want to do that becouse, when I start writing on my EditText the highlight overlap the rounded corners of my EditText, and it looks bad.

Code for background color and corner rounded of my EditText:

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

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">    
<corners android:radius="5dp" />
<solid android:color="#FFFFFF"/> 

</shape>

Code of my edittext:

<EditText
        android:id="@+id/editTextUsuario"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/propertieseditextlogin"
        android:ems="10" >
<requestFocus />
</EditText>

There are 2 examples of my problem:

Was it helpful?

Solution 4

Solution of your second problem

Give padding to your EditText

Example:-

<EditText
        android:id="@+id/editTextUsuario"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/propertieseditextlogin"
        android:paddingLeft="6dp"
        android:ems="10" >
<requestFocus />
</EditText>

OTHER TIPS

Try adding this attribute to your editText to disable highlighting.

android:defaultFocusHighlightEnabled="false"

You can create highlight with rounded corners programmatically by creating custom View extending edit text, but that's really lot of work. Also have a look for material design, with this library you can implement edit text with rounded corners pretty easily.

To disable the highlight of the edittext, you can just write following.

android:background="#00000000"

Give the editext a padding using android:padding or set the background attribute to white

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top