两侧带图标编辑文本 [英] Edit text with icons on both sides

查看:159
本文介绍了两侧带图标编辑文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须做一个编辑文本里面坐了两个字体真棒图标:

我的问题是添加这些图标(左,右),我该怎么办呢?

下面是我的custom_search.xml绘制文件:

 < XML版本=1.0编码=UTF-8&GT?;
<形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:形状=矩形机器人:填充=10dp>
    [固体机器人:颜色=#FFFFFF/>
    <角落
        机器人:bottomRightRadius =5DP
        机器人:bottomLeftRadius =5DP
        机器人:topLeftRadius =5DP
        机器人:topRightRadius =5DP/>
    <行程机器人:颜色=@色/ grayLighter机器人:宽=1DP/>
< /形状>
 

解决方案

您可以使用 drawableLeft drawabelRight 的您的XML像如下:

 <的EditText
    机器人:ID =@ + ID / et_drawables_added
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:drawableRight =@可绘制/ ic_launcher
    机器人:drawableLeft =@可绘制/ ic_launcher/>
 

有更多的选择,如 drawableTop drawableBottom 。你可以尝试一下,反正你想要的。

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>

解决方案

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.

这篇关于两侧带图标编辑文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆