TextInputLayout endIconDrawable 顯示為灰色而不是所需的影像。
只有此影像呈現為灰色。我嘗試將影像作為 png 并將 svg 作為矢量資產匯入。
兩者都沒有按預期作業。
我嘗試在 TextInputLayout 中設定影像:
<com.google.android.material.textfield.TextInputLayout
android:id="@ id/chatFragment_TIL1"
android:layout_width="match_parent"
android:layout_height="50dp"
app:boxBackgroundMode="outline"
android:layout_toRightOf="@id/chatFragment_imageView2"
android:layout_marginStart="15dp"
app:boxCornerRadiusTopStart="@dimen/TIL_CornerRadius2"
app:boxCornerRadiusTopEnd="@dimen/TIL_CornerRadius2"
app:boxCornerRadiusBottomStart="@dimen/TIL_CornerRadius2"
app:boxCornerRadiusBottomEnd="@dimen/TIL_CornerRadius2"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_message_send_icon"
style="@style/TextInputLayoutStyle"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="@ id/chatFragment_TIET1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:fontFamily="@font/inter_regular"
android:textColor="@color/black_text_dark"
android:hint="@string/chatFragment_Text1"
android:textSize="@dimen/normalText1"
/>
</com.google.android.material.textfield.TextInputLayout>
我也在文本輸入更改上更改它,如下所示:
if(s.length() > 0){
inputMessageTIL.setEndIconDrawable(R.drawable.ic_message_send_icon);
} else {
inputMessageTIL.setEndIconDrawable(R.drawable.ic_mic);
}
這是vectordrawable代碼:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M16,16m-16,0a16,16 0,1 1,32 0a16,16 0,1 1,-32 0"
android:fillColor="#6B4EFF"/>
<path
android:pathData="M22.5,9.5L14.25,17.75M22.5,9.5L17.25,24.5L14.25,17.75M22.5,9.5L7.5,14.75L14.25,17.75"
android:strokeLineJoin="round"
android:strokeWidth="1.5"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
</vector>
這是我使用的 png 格式的影像

這就是我現在得到的..灰色圓圈影像..

請幫我。我不能使用其他影像。非常感謝!
uj5u.com熱心網友回復:
使用 endIconTint 設定顏色
app:endIconTint="@color/redText"
app:endIconTintMode="multiply"
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/447495.html
標籤:安卓 安卓文本输入布局 android-vectordrawable
下一篇:Tomcat發送“Cross-Origin-Opener-Policy”和“Cross-Origin-Embedder-Policy”標頭以在JavaScript上啟用SharedArrayBuffe
