我想在 EditText 中放置一个图像按钮,但我没有 Idea 请告诉我如何操作,如图所示。谢谢
最佳答案
如果您不想点击该图像,那么您可以使用 EditText 的 drawableRight
属性..
android:drawableRight="@drawable/icon"
如果你想点击然后使用下面的代码。
<?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>
关于android - 如何在 EditText 中放置按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13151366/