我一直在阅读关于SO的帖子,但没有一个解决方案解决了我的问题。
我使用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>
结果如下:
我尝试过针对类似问题找到的任何解决方案,试图将spinner
下划线与EditTxt
对齐。但是,没有帮助。例如this post。
我正在寻找解决此问题的解决方案或解决方法。
由于
答案 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"
你会没事的