为什么TextInputLayout上的Drawable不清晰可见?

问题描述 投票:0回答:1

我正在尝试向文本字段添加一个麦克风按钮,以便用户可以说话,并将其翻译为文本。
我的布局如下所示:

 <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/descriptionLayout"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/volunteering_description"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/projectLayout"
        app:endIconMode="custom"
        app:endIconDrawable="@drawable/ic_microphone"
        app:endIconContentDescription="Voice Input"
        android:layout_marginTop="@dimen/default_margin">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/etDescription"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minLines="2" />
    </com.google.android.material.textfield.TextInputLayout>

单独查看时,该图标看起来很像黑白,但是当添加到

TextInputLayout
中时,它会变灰并且不清晰可见:

enter image description here

我已经尝试过

app:boxBackgroundMode="none"
,但也没有帮助。

有人有如何解决的建议吗?

可以通过此链接找到原始图标

java android android-textinputlayout android-textinputedittext
1个回答
0
投票

我无法使用您的确切代码重现该问题,因此您创建的可绘制对象可能有问题。请尝试像这样创建您的绘图:

右键单击 Android Studio 中的

res
文件夹,然后选择
New
->
Image Asset

Screenshot

然后,切换到顶部的“操作栏和选项卡图标”选项卡:

[Tab Selection Screenshot2

最后,选择

keyboard voice
作为剪贴画,然后单击“下一步”->“创建”:

Creation Screenshot

覆盖任何当前文件。然后,输出应如下所示:

Output

© www.soinside.com 2019 - 2024. All rights reserved.