0

Hi in the below code I am trying to displaying a simple Material design with TextInputEditText name as Firstname with mandatory symbol as asterisk symbol .But Asterisk symbol is not displaying in red color.

Can any one help me where I did the mistake Please have a look I am uploading my screenshot as a refrence new.xml:

 <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/firstnames"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:padding="5dp"
                            android:textColorHint="@color/theme"
                            style="@style/myTextInputLabel">

                            <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/firstname"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="text"
                                android:hint="@string/firstname"
                                android:textSize="16sp" />
                        </com.google.android.material.textfield.TextInputLayout>

Strings.xml:

<string name="firstname">First Name <font fgcolor='#FF0000'>*</font></string>

Styles.xml:

<style name="myTextInputLabel" parent="TextAppearance.AppCompat">
        <!-- Customize your theme here. -->
        <item name="android:textSize">20sp</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="colorControlNormal">@color/theme</item>
        <item name="colorControlActivated">@color/theme</item>
        <item name="android:textColor">@color/theme</item>
        <item name="colorControlHighlight">@color/theme</item>
    </style>
jyothi sri
  • 51
  • 6
  • Maybe this will help you: https://stackoverflow.com/questions/30546430/how-to-change-the-floating-label-color-of-textinputlayout You might need to extend the TextInputLayout to achieve what you want. – Rahul Shukla Dec 09 '20 at 05:03

1 Answers1

0

You need minimum version 1.2.0-alpha05 of the material library for it to work.

You need to create the string like this:

<string name="firstname">First Name <font fgcolor='#FF0000'>*</font></string>

Also, the style should not be set as a theme in TextInputLayout, it should be set like this:

style="@style/myTextInputLabel"

... and the textColorHint should be set on TextInput Layout, not the TextInputEditText.

jana
  • 256
  • 1
  • 4