问题
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