Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在启用PasswordToggleLeft的情况下添加drawableStart/drawableLeft_Java_Android_Android Studio - Fatal编程技术网

Java 无法在启用PasswordToggleLeft的情况下添加drawableStart/drawableLeft

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

我还尝试使用java代码添加它

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;