Edit text with icons on both sides

混江龙づ霸主 提交于 2019-12-09 21:43:24

问题


I have to do an Edit Text with two Font Awesome Icons inside it:

My problem is to add these icons (Left and Right), how can I do it?

Here is my custom_search.xml drawable file:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">
    <solid android:color="#FFFFFF"/>
    <corners
        android:bottomRightRadius="5dp"
        android:bottomLeftRadius="5dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp"/>
    <stroke android:color="@color/grayLighter" android:width="1dp"/>
</shape>

回答1:


You can use drawableLeft and drawabelRight in your xml like follows:

<EditText
    android:id="@+id/et_drawables_added"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawableRight="@drawable/ic_launcher"
    android:drawableLeft="@drawable/ic_launcher"" />

There are more options, like drawableTop, drawableBottom. You can try them anyway you want.




回答2:


you can do :

 <EditText 

    android:drawableLeft="your drawable"
    android:drawableRight="your drawable"
    />

hope this will help.



来源:https://stackoverflow.com/questions/28235570/edit-text-with-icons-on-both-sides

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!