微调器下方的下划线未与EditText的下划线对齐

时间:2017-06-16 12:24:53

标签: android xml android-spinner

我一直在阅读关于SO的帖子,但没有一个解决方案解决了我的问题。 我使用style="@style/Base.Widget.AppCompat.Spinner.UnderlinedSpinner添加下划线但是由于某些原因,微调器的baseline未与EditText对齐。 这是我的 XML:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="5">

    <!-- Phone Country code Spinner -->
    <Spinner
        android:id="@+id/spProfileDetailsUser_phoneNumberCode"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        style="@style/Base.Widget.AppCompat.Spinner.Underlined"
        android:layout_gravity="bottom">
    </Spinner>

    <!--  Mobile Number Label -->
    <android.support.design.widget.TextInputLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:layout_weight="4">
        <EditText android:id="@+id/etProfileDetailsUser_phoneNumber"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inputType="number"
            android:hint="Mobile Number"
            />
    </android.support.design.widget.TextInputLayout>
</LinearLayout>

结果如下:

enter image description here

我尝试过针对类似问题找到的任何解决方案,试图将spinner下划线与EditTxt对齐。但是,没有帮助。例如this post

我正在寻找解决此问题的解决方案或解决方法。

由于

2 个答案:

答案 0 :(得分:3)

只需删除android:layout_marginBottom =&#34; 8dp&#34;来自TextInputLayout:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="5"
xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Phone Country code Spinner -->
<Spinner
    android:id="@+id/spProfileDetailsUser_phoneNumberCode"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    style="@style/Base.Widget.AppCompat.Spinner.Underlined"
    android:layout_gravity="bottom">
</Spinner>

<!--  Mobile Number Label -->
<android.support.design.widget.TextInputLayout
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:layout_weight="4">
    <EditText android:id="@+id/etProfileDetailsUser_phoneNumber"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:inputType="number"
              android:hint="Mobile Number"
        />
</android.support.design.widget.TextInputLayout>

答案 1 :(得分:1)

摆脱

android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"

你会没事的