passwordToggle正在删除TextInputEditText中的drawable

时间:2018-04-10 08:45:23

标签: android android-textinputlayout

我尝试创建一个密码字段,左侧是锁定图标,右侧是密码切换图标.....但我无法同时显示这两个图标....我该如何解决?

1 个答案:

答案 0 :(得分:1)

试试这个:

  <android.support.design.widget.TextInputLayout
          android:id="@+id/textInputLayoutPassword"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginEnd="@dimen/margin_20dp"
          android:layout_marginStart="@dimen/margin_20dp"
          android:layout_marginTop="@dimen/margin_8dp"
          android:theme="@style/EditTextHint"
          app:errorTextAppearance="@style/error_appearance"
          app:hintTextAppearance="@style/hint_appearance"
          app:passwordToggleEnabled="true">

         <EditText
                android:id="@+id/editTextPassword"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/L_PASSWORD"
                android:inputType="textPersonName"
                android:paddingBottom="@dimen/margin_20dp"
                android:drawableStart="@drawable/ic_lock"
        tools:ignore="TextFields" />
  </android.support.design.widget.TextInputLayout>

我试过它运作良好:))

<强> O / P

enter image description here