微调器下方的下划线未与 EditText 的下划线对齐
Underline below spinner is not aligning with EditText's Underline
我一直在阅读关于 SO 的帖子,none 的解决方案解决了我的问题。
我使用 style="@style/Base.Widget.AppCompat.Spinner.Underlined
为 Spinner
添加下划线,但由于某些原因,微调器的 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>
结果如下:
我已经尝试过我在 SO 上尝试将 spinner
下划线与 EditTxt
对齐的类似问题的任何解决方案。然而,没有帮助。比如.
我正在寻找解决此问题的解决方案或解决方法。
谢谢
只需从您的 TextInputLayout 中删除 android:layout_marginBottom="8dp":
<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>
去掉
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
你会没事的
我一直在阅读关于 SO 的帖子,none 的解决方案解决了我的问题。
我使用 style="@style/Base.Widget.AppCompat.Spinner.Underlined
为 Spinner
添加下划线,但由于某些原因,微调器的 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>
结果如下:
我已经尝试过我在 SO 上尝试将 spinner
下划线与 EditTxt
对齐的类似问题的任何解决方案。然而,没有帮助。比如
我正在寻找解决此问题的解决方案或解决方法。
谢谢
只需从您的 TextInputLayout 中删除 android:layout_marginBottom="8dp":
<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>
去掉
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
你会没事的