1

I am using TextInputLayout around edittext. I want to change the border color of the edit text which is present inside the TextInputLayout.

xml

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <android.support.design.widget.TextInputEditText
            android:id="@+id/Test1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </android.support.design.widget.TextInputLayout>

Csharp

    private TextInputEditText editor;
    editor = FindViewById<TextInputEditText>(Resource.Id.Test6);
    editor.Background.SetColorFilter(Android.Graphics.Color.Red, Android.Graphics.PorterDuff.Mode.SrcAtop);

This above code works correctly, if the edit text is not present inside the TextInputLayout. Only gets problem while using the edittext inside the TextInputLayout. How can I fix this?

Ragul S V
  • 139
  • 6

2 Answers2

1

create drawable file in drawable folder i.e. drawable_name.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

  <!-- Background Color -->
  <solid android:color="#ffffff" />

  <!-- Border Color -->
  <stroke android:width="1dp" android:color="#e7e7e7e7" />

  <!-- Round Corners -->
  <corners android:radius="5dp" />

</shape>

and set this drawable to edittext

 drawble = "@drawable/drawble_name"
 

change color of border as per your requirement

Saad Khan
  • 180
  • 2
  • 12
1

put the style in your style,

<style name="LoginTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxStrokeColor">#fff</item>
    <item name="boxStrokeWidth">2dp</item>
</style>

and add the following color to your color.xml

<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">#fff</color>

Change the TextInputLayout outline color

sadat
  • 4,004
  • 2
  • 29
  • 49