Android 如何使用EditText在一行中设置微调器

Android 如何使用EditText在一行中设置微调器,android,android-edittext,android-spinner,Android,Android Edittext,Android Spinner,我想同时使用EditText和Spinner。微调器应位于EditText的末尾并加下划线。如何在一行中设置微调器的下划线和编辑文本的下划线 以下不是整个xml文件,而是其中的一部分: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="

我想同时使用
EditText
Spinner
微调器应位于EditText的末尾并加下划线。如何在一行中设置
微调器的下划线和
编辑文本的下划线

以下不是整个xml文件,而是其中的一部分:

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <Spinner
                android:id="@+id/spinner_currency"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentBottom="true">

            </Spinner>

            <com.wrapp.floatlabelededittext.FloatLabeledEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@id/spinner_currency"
                android:layout_toStartOf="@id/spinner_currency"
                app:fletTextAppearance="@style/FloatLabelEditTextStyle">

                <com.rengwuxian.materialedittext.MaterialEditText
                    android:id="@+id/material_edit_text_amount"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:fontFamily="sans-serif"
                    android:hint="Amount"
                    android:inputType="number"
                    android:maxLength="15"
                    android:textColor="@color/colorPrimaryText"
                    android:textSize="16sp"
                    app:met_helperTextAlwaysShown="true"
                    app:met_helperTextColor="@color/colorSecondaryText"
                    app:met_iconPadding="0dp"
                    tools:targetApi="jelly_bean" />
            </com.wrapp.floatlabelededittext.FloatLabeledEditText>
        </RelativeLayout>

您可以使用FrameLayout而不是RelativeLayout。如您所知,在FrameLayout中创建的最后一个对象位于顶部

注意:无论使用哪种微调器。我喜欢材质微调器,我已经用过了

这看起来像 像这样尝试

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.wrapp.floatlabelededittext.FloatLabeledEditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp">

    <com.rengwuxian.materialedittext.MaterialEditText
        android:id="@+id/material_edit_text_amount"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif"
        android:hint="Amount"
        android:inputType="number"
        android:maxLength="15"
        android:textSize="16sp"
        app:met_helperTextAlwaysShown="true"
        app:met_iconPadding="0dp"
        tools:targetApi="jelly_bean" />
</com.wrapp.floatlabelededittext.FloatLabeledEditText>

<com.jaredrummler.materialspinner.MaterialSpinner
    android:id="@+id/spinner_currency"
    android:layout_gravity="end"
    android:layout_marginRight="16dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:entries="@array/actions">

</com.jaredrummler.materialspinner.MaterialSpinner>


创建一个宽度与父视图匹配、高度为1、宽度为下划线颜色的视图,并将其设置在RelativeLayout的底部。谢谢!太容易了:)