如何在 EditText 中放置按钮 [英] How to place button inside of EditText

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

问题描述

我想在 EditText 中放置一个图像按钮,但我没有 Idea 请告诉我如何操作,如图所示.谢谢

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

推荐答案

如果你不想点击那个图片,那么你可以使用 EditText 的 drawableRight 属性..

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

android:drawableRight="@drawable/icon"

如果你想点击然后使用下面的代码.

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="match_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:layout_width="match_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>

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

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