Change the underline of android textfields in Titanium Alloy

475 views Asked by At

I am trying to change the underline color of Android textfields in Titanium Alloy using a custom theme, but for some reason it doesn't pick up my new colors(s).

Titanium Alloy textfield underline

I have created a theme under project/app/platform/android/res/values/awesome_theme.xml with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="awesome" parent="@style/Theme.AppCompat">
        <item name="colorControlNormal">#ff0000</item>
        <item name="colorControlActivated">#00ff00</item>
        <item name="colorControlHighlight">#0000ff</item>
    </style>
</resources>

And I have changed my tiapp.xml file to use the new theme:

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:theme="@style/awesome"/>
</android>

I have cleaned the project, but the text field is still showing up with the default blue underline when I rebuild the project.

What am I doing wrong here?

1

There are 1 answers

7
Charuක On

You have to use a different background image, go to your XML "awesome_theme.xml" and add the custom EditText style

 <style name="EditTextCustomHolo" parent="android:Widget.EditText">
       <item name="android:background">@drawable/apptheme_edit_text_holo_light</item>
       <item name="android:textColor">#ffffff</item>
    </style>

insted of using image drawble file--> apptheme_edit_text_holo_light in that EditText style you can use a drawable resource file which has a stroke , go with that one or this stroke one ,

 <?xml version="1.0" encoding="utf-8"?>
 <item>
    <shape android:shape="rectangle">
        <stroke
            android:width="1dp"
            android:color="@color/white"/>
    </shape>
</item>

then Just do this in your EditText:

<EditText
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   style="@style/EditTextCustomHolo"/>

or

you can change Underline of EditText color specifying it in awesome_theme.xml. add the following tag under your style Theme.AppCompat.

<item name="android:textColorSecondary">@color/primary_text_color</item>

Note : android:textColorSecondary is used to determine the color of the back arrow and DrawerLayout hamburger icon in the ActionBar, too soo careful