在android中如何在文本字段中嵌入图标?
我正在尝试实现一个密码字段,其中有一个眼睛图标。在android中如何在文本字段中嵌入图标?,android,android-layout,compound-drawables,Android,Android Layout,Compound Drawables,我正在尝试实现一个密码字段,其中有一个眼睛图标。 我使用制作动画 但是,眼睛图标会继续显示在编辑文本下 这是我的密码: <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marg
我使用
制作动画
但是,眼睛图标会继续显示在编辑文本下
这是我的密码:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<EditText
android:id="@+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" />
<ImageView
android:id="@+id/fragment_login_password_visibility"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignRight="@+id/fragment_login_password"
android:clickable="true"
android:src="@drawable/ic_show_password" />
</android.support.design.widget.TextInputLayout>
非常感谢您的帮助。将android:drawableLeft=“@drawable/ic\u show\u password”添加到您的编辑文本中。
然后去掉ImageView
您可以使用复合drawables将图标放置在视图的左侧(如我的示例中)、右侧、顶部和/或底部。将android:drawableLeft=“@drawable/ic\u show\u password”添加到编辑文本中。
然后去掉ImageView
您可以使用复合绘图功能将图标放置在视图的左侧(如我的示例中)、右侧、顶部和/或底部。我认为您应该查看此帖子我认为您应该查看此帖子现在图标位于视图内部,而不是视图外部。;)对谢谢!现在图标位于视图内,而不是视图外。;)对谢谢!