EditText结束图标自动变化
EditText end icon changes automatically
EditText 图标无法正常工作
在 EditText 中,我为所有图标添加了结束图标 app:endIconDrawable="@mipmap/edit_icon"
,它变成了灰色方块
更新代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/profile_user_name_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="@string/user_name"
app:endIconMode="custom"
app:endIconTintMode="screen"
app:endIconDrawable="@mipmap/edit_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/profile_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
实际图标
更新代码的输出
设置 app:endIconTintMode="screen"
应该可以解决问题。如果没有此属性,我的图标也不可见 app:endIconMode="custom"
EditText 图标无法正常工作
在 EditText 中,我为所有图标添加了结束图标 app:endIconDrawable="@mipmap/edit_icon"
,它变成了灰色方块
更新代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/profile_user_name_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="@string/user_name"
app:endIconMode="custom"
app:endIconTintMode="screen"
app:endIconDrawable="@mipmap/edit_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/profile_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
实际图标
更新代码的输出
设置 app:endIconTintMode="screen"
应该可以解决问题。如果没有此属性,我的图标也不可见 app:endIconMode="custom"