gpt4 book ai didi

android - 如何使用 passwordToggleEnabled 在 AppCompatEditText 中显示左侧可绘制对象?

转载 作者:行者123 更新时间:2023-11-29 02:39:54 25 4
gpt4 key购买 nike

添加 passwordToggleEnabled="true"时,我有一个 AppCompatEditText 我的左侧可绘制对象消失了。可能是什么原因?

密码编辑文本代码:

<android.support.design.widget.TextInputLayout
app:passwordToggleEnabled="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="20dp"
android:inputType="textPassword"
android:hint="@string/password_hint"
android:paddingLeft="15dp"
android:theme="@style/EditTextTheme"/>
</android.support.design.widget.TextInputLayout>

EditText 可绘制代码:

_passwordEditText.setCompoundDrawablesWithIntrinsicBounds(passwordIcon, null, null, null);

使用 app:passwordToggleEnabled="true":

enter image description here

没有它:

enter image description here

编辑:我可以在顶部和底部设置可绘制对象,但它对左侧和右侧不起作用。

最佳答案

试试这个,而不是将 null 设置为现有的 drawable,获取 drawable 并将你的设置在左侧。

Drawable[] drawables = _passwordEditText.getCompoundDrawables();

_passwordEditText.setCompoundDrawablesWithIntrinsicBounds(passwordIcon, drawables[1], drawables[2], drawables[3]);

(来源:Stack Overflow 文档中的示例“自定义编辑文本中的图标或按钮及其操作和点击监听器”;版权所有 2017 by Muthukrishnan Rajendran;根据 CC BY-SA 3.0 获得许可。archive of the full Stack Overflow Documentation content 可以可在 archive.org 上找到,其中此示例由主题 ID 5843 和示例 ID 32126 索引。)

关于android - 如何使用 passwordToggleEnabled 在 AppCompatEditText 中显示左侧可绘制对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44977059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com