oOOMIAO 2012-10-31 05:52 采纳率: 10%
浏览 8571
已采纳

如何在编辑框添加一个按钮?

我想要在EditText里面添加一个图片按钮,但是不知道怎么做,我想实现的效果如下图:

enter image description here

多谢指教~

  • 写回答

4条回答

  • Chengzi_963 2012-10-31 09:13
    关注

    不实现点击:

    android:drawableRight="@drawable/icon"
    

    实现点击的代码:

    <?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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!