Issue
I am setting a an icon in material TextInputLayout but the icon is showing as grey not its original color(Shown in the image below). Using the same icon image in a Image View is showing colors. I have searched a lot and haven't found any solutions.
Any help will be great. Thanks in advance.
XML for the TextInputLayout :-
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/country"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/country"
app:layout_constraintBottom_toBottomOf="parent"
app:startIconDrawable="@drawable/flag"
app:layout_constraintStart_toStartOf="parent"
android:layout_margin="10dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+91"
android:enabled="false"/>
</com.google.android.material.textfield.TextInputLayout>
Solution
Simply add this line to your xml TextinputLayout Xml file
app:startIconTint="@null"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/country"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="کشور"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:startIconDrawable="@drawable/blue_cheese"
app:startIconTint="@null">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="+91" />
</com.google.android.material.textfield.TextInputLayout>
Answered By - Hamed Heidari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.