Java 无法在启用PasswordToggleLeft的情况下添加drawableStart/drawableLeft
我还尝试使用java代码添加它Java 无法在启用PasswordToggleLeft的情况下添加drawableStart/drawableLeft,java,android,android-studio,Java,Android,Android Studio,我还尝试使用java代码添加它 password.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, 0, 0, 0); 我还搜索了解决此问题的方法,但没有找到任何结果,我只找到了drawableStart,它也不起作用。它对我有效: 使用TextInputLayout,它具有密码切换功能。 如下 <android.support.design.widget.TextInputLayout android:layo
password.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, 0, 0, 0);
我还搜索了解决此问题的方法,但没有找到任何结果,我只找到了drawableStart,它也不起作用。它对我有效:
使用TextInputLayout,它具有密码切换功能。
如下
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
android:hint="enter name"
app:passwordToggleTint="@color/colorPrimary"
android:textColorHint="@color/colorPrimary"
android:layout_marginBottom="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="parent">
<android.support.design.widget.TextInputEditText
android:drawableLeft="@drawable/share_red"
android:drawablePadding="10dp"
android:inputType="numberPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/share_red" />
</android.support.design.widget.TextInputLayout>
这对我很有用:
使用TextInputLayout,它具有密码切换功能。
如下
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
android:hint="enter name"
app:passwordToggleTint="@color/colorPrimary"
android:textColorHint="@color/colorPrimary"
android:layout_marginBottom="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="parent">
<android.support.design.widget.TextInputEditText
android:drawableLeft="@drawable/share_red"
android:drawablePadding="10dp"
android:inputType="numberPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/share_red" />
</android.support.design.widget.TextInputLayout>
尝试:
与之相比:
setCompoundDrawablesRelativeWithIntrinsicBounds
尝试:
与之相比:
setCompoundDrawablesRelativeWithIntrinsicBounds
是的,我使用的是textinputlayout,这就是问题所在。试试看,这可能会对你有帮助是的,我使用的是textinputlayout,这就是问题所在。试试看,这可能会对你有帮助。你试图用实用主义的方法设置复合绘图,而你使用的是密码。setCompoundDrawablesRelativeWithIntrinsicBoundsdrawable,0,0;与此相比,请尝试以下密码:setCompoundDrawablesWithIntrinsicBoundsR.drawable.yourIconName,0,0;您正在尝试以实用的方式设置复合drawable,并使用密码。setCompoundDrawablesRelativeWithIntrinsicBoundsdrawable,0,0;与此相比,请尝试以下密码:setCompoundDrawablesWithIntrinsicBoundsR.drawable.yourIconName,0,0;