I want to change the underline color of a custom AutoCompleteTextView
, like the blue color under Phone Number below to other color, and remvoe about 2dp space above the underline (please note that vertial line one both ends).
I cannot find solution for the problem on the web.
Before I created the custom AutoCompleteTextView, I changed underline color for the built-in AutoCompleteTextView
via accent on colors.xml like below.
<resources>
...
<color name="accent">#206DDA</color>
...
</resources>
However, after a custom AutoCompleteTextView
is used in place of the built-in AutoCompleteTextView
, the underline color uses default color, like the image above.
I tried below but it does not work: styles.xml below:
<style name="Autocomplete" parent="Widget.AppCompat.Light.AutoCompleteTextView">
<item name="colorControlActivated">@color/primary</item>
</style>
activity.xml below:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<MyAutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Phone number"
android:completionThreshold="1"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionNext"
android:theme="@style/Autocomplete"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
</android.support.design.widget.TextInputLayout>
Below is my AutoCompleteTextView:
public class MyAutoCompleteTextView: AutoCompleteTextView
{
public MyAutoCompleteTextView(Context context, IAttributeSet attrs)
: base(context, attrs)
{
}
public override bool EnoughToFilter()
{
return true;
}
}
Use android:backgroundTint
to change color of MyAutoCompleteTextView
. Like
<MyAutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
.......
android:backgroundTint="#FF0000" />
To make more customizable, change parent class of MyAutoCompleteTextView
to AppCompatAutoCompleteTextView
instead AutoCompleteTextView