可能重複:
Android Labels or Bubbles in EditText按鈕上的EditText在Android中
我怎麼可以把按鈕上EditText
這樣的:
我只找到如何把'X'放在EditText
的末尾,但我無法涉及如何使用這個,因爲我想要的。當然,我正在談論android。
可能重複:
Android Labels or Bubbles in EditText按鈕上的EditText在Android中
我怎麼可以把按鈕上EditText
這樣的:
我只找到如何把'X'放在EditText
的末尾,但我無法涉及如何使用這個,因爲我想要的。當然,我正在談論android。
如果你想有一個按鈕,你的EditText的右邊,你可以如果你想要一個實際的X使用圖像按鈕,像這樣
<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>
包裝在一個水平線性佈局。
編輯:哦,對於更多的控制,你可以使用android:weight=""
屬性給編輯文本的屏幕寬度擴大比例。
謝謝,但我知道如何用X按鈕進行操作。我想要這個按鈕名稱 – 2012-03-03 10:49:36
@ user1189159哦,「x」在未知的情況下,而不是在取消「x」。我的錯誤 – Jack 2012-03-03 11:23:41
另一種選擇(如果我深知你想要的)是這樣的:
<?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>
試試吧。
正是你想要的是什麼http://stackoverflow.com/questions/8090711/android-labels-or-bubbles-in-edittext – 2012-03-03 10:36:18
謝謝,這正是我想要的:) – 2012-03-03 10:50:51