我想为TextInputLayout设置一个可绘制的背景,这是我的代码:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_repass"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginTop="10dp"
app:hintEnabled="false"
android:layoutDirection="rtl"
app:passwordToggleEnabled="true">
<EditText
android:id="@+id/repass"
style="@style/edittexts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_repass"
android:drawableRight="@drawable/ic_https_grey600_18dp"
android:inputType="textPassword"
android:nextFocusDown="@+id/email" />
</android.support.design.widget.TextInputLayout>
问题是,图标没有出现,原因是passwordToggleEnabled
当我删除它时,它显示了可绘制的
如何同时显示PasswordToggle Drawable
和background drawable
?
答案 0 :(得分:3)
使用
android:drawableStart="@drawable/ic_launcher_round"
而不是
android:drawableRight="@drawable/ic_launcher_round"
试试这个
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_repass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layoutDirection="rtl"
app:hintEnabled="false"
app:passwordToggleEnabled="true">
<EditText
android:id="@+id/repass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_launcher_round"
android:hint="nilu"
android:imeOptions="actionNext"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
注意: android:drawableStart="@drawable/ic_launcher_round"
因android:layoutDirection="rtl"
<强>输出强>
答案 1 :(得分:0)
试试这个
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/rl_main"
android:padding="@dimen/margin_30dp"
android:background="@color/white_color">
<ImageView
android:id="@+id/img_email"
android:layout_width="@dimen/margin_25dp"
android:layout_height="@dimen/margin_25dp"
android:src="@drawable/message"
android:layout_marginTop="@dimen/margin_15dp"
android:layout_alignParentLeft="true"
/>
<!--Email-->
<android.support.design.widget.TextInputLayout
android:id="@+id/til_email_login_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:hint="@string/email"
android:textColorHint="@color/gray">
<com.xxx.app.customeview.CustomFontEditText
android:id="@+id/et_email_login_activity"
style="@style/edit_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:text="" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
密码使用密码使用app:passwordToggleEnabled =“false”
答案 2 :(得分:0)
您只需添加此行
android:drawableStart="@drawable/ic_action_rupee"
使用此代码它将为我工作。
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_repass"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginTop="10dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true">
<EditText
android:id="@+id/repass"
style="@style/edittexts"
android:drawableStart="@drawable/ic_action_rupee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_repass"
android:inputType="textPassword"
android:nextFocusDown="@+id/email"
android:drawableLeft="@drawable/ic_action_rupee" />
</android.support.design.widget.TextInputLayout>