如何放置按钮编辑文本的内部 [英] How to place button inside of edit text

查看:135
本文介绍了如何放置按钮编辑文本的内部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想放置一个图像按钮的EditText里面,但我没有想法,请告诉我该怎么做,从而如图所示。谢谢

I want to place an image button inside of EditText, but I don't have Idea please tell me how to do so as shown in the figure . Thanks

推荐答案

如果您不想点击该图片,然后你可以用 drawableRight 属性的EditText ..

If You dont want click on that Image, Then you can use drawableRight property for EditText..

android:drawableRight="@drawable/icon"

如果你想点击然后用下面code。

If you want click then use below code.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Enter search key" />

    <ImageButton
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:src="@drawable/search"
        android:layout_centerVertical="true"
        android:layout_margin="5dp"
        android:text="Button"/>

</RelativeLayout>

这篇关于如何放置按钮编辑文本的内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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