我想在android中的编辑文本中有一个按钮

时间:2016-05-21 08:26:49

标签: android android-layout android-edittext android-button

我希望Button内有editText。我正在附加屏幕截图。我怎样才能做到这一点?请帮帮我。

这样的事情:

img

2 个答案:

答案 0 :(得分:0)

您可以使用以下代码。

<?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" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_margin="5dp"
        android:text="Verify"/>

</RelativeLayout>

答案 1 :(得分:0)

<?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="wrap_content"
android:orientation="horizontal" >

    <EditText
    android:layout_gravity="1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Mobile no" >

    <Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Verify"/>

    </EditText>

</LinearLayout>