简体   繁体   English

编辑带有两侧图标的文本

[英]Edit text with icons on both sides

I have to do an Edit Text with two Font Awesome Icons inside it: 我必须在里面做两个Font Awesome图标的编辑文本: 在此输入图像描述

My problem is to add these icons (Left and Right), how can I do it? 我的问题是添加这些图标(左和右),我该怎么办?

Here is my custom_search.xml drawable file: 这是我的custom_search.xml可绘制文件:

<?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>

You can use drawableLeft and drawabelRight in your xml like follows: 您可以在xml中使用drawableLeftdrawabelRight ,如下所示:

<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 . 还有更多选项,例如drawableTopdrawableBottom You can try them anyway you want. 无论如何你都可以试试。

you can do : 你可以做 :

 <EditText 

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

hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM