0

So, I use TextInputLayout and EditText to input email, but I have some trouble with hint placement. I also don't know how to change the color of this "I" symbol. Here is my XML for this email field:

<com.google.android.material.textfield.TextInputLayout style="@style/ThemeOverlay.Material3.AutoCompleteTextView.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:textColorHint="@color/black" app:hintTextColor="@color/black" app:boxStrokeColor="@color/black"> <EditText android:layout_width="350dp" android:layout_height="wrap_content" android:hint="@string/test_email" android:textSize="20sp" android:id="@+id/logEmail" android:layout_gravity="center" android:inputType="textEmailAddress" android:layout_marginTop="20dp" android:layout_marginStart="30dp" android:layout_marginEnd="30dp" android:textColorHint="#616161"/> </com.google.android.material.textfield.TextInputLayout> 
1
  • I forgot to add an image for this problem. Here is an example Commented May 29, 2024 at 12:50

1 Answer 1

1

Couple of mistakes here:

  1. Wrong child view for com.google.android.material.textfield.TextInputLayout.
  2. Wrong style attribute value.
  3. android:hint="@string/test_email" is used at wrong place.

Use code below:

<com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:hint="app" app:cursorColor="@android:color/holo_red_dark" app:hintEnabled="true"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/logEmail" android:layout_width="350dp" android:layout_height="wrap_content" android:inputType="textEmailAddress" /> </com.google.android.material.textfield.TextInputLayout> 

In the code above:

  1. Have corrected all the errors.
  2. Used app:cursorColor to define caret (the "|" thing) color.
Sign up to request clarification or add additional context in comments.

2 Comments

Oh my God, thank you so much! It really helped me. I wish you all the best and success!
Hi @arctg30, you can accept the answer as it solved your problem. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.