如何使用 EditText 在一行中设置 Spinner
How to set Spinner in one line with EditText
我想同时使用 EditText
和 Spinner
。 Spinner
应该在 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 中创建的最后一个对象位于顶部。
注意:无论您使用哪种微调器。我喜欢 material 旋转器,我已经用过了。
这看起来像 this
像这样尝试 ;
<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>
我想同时使用 EditText
和 Spinner
。 Spinner
应该在 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 中创建的最后一个对象位于顶部。
注意:无论您使用哪种微调器。我喜欢 material 旋转器,我已经用过了。
这看起来像 this 像这样尝试 ;
<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>