Possible Duplicate:
Android Labels or Bubbles in EditText
How can i put buttons on EditText
like this:
I only find how to put 'X' at the end of EditText
, but I couldn't relate how to use this as I want. Of course I'm talking about android.
Possible Duplicate:
Android Labels or Bubbles in EditText
How can i put buttons on EditText
like this:
I only find how to put 'X' at the end of EditText
, but I couldn't relate how to use this as I want. Of course I'm talking about android.
If you want a button to the right of your edittext you could wrap it in a horizontal linear layout like so
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editSearchContact"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button android:id="@+id/xbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
If you want an actual X use image button.
EDIT: Oh and for more control you can use the android:weight=""
attribute to give the edit text a ratio of the width of the screen to expand to.
Another option(if i understood well what you want) is this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- This LinearLayout will be your EditText that holds two Buttons with name and also image-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background" >
<Button
android:id="@+id/the_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="7dp"
android:background="@drawable/draw_the_button"
android:padding="5dp"
android:text="Name Here" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:layout_gravity="center_vertical" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_input_add"
android:layout_gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
Try it.