2017-06-16 50 views
3

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

<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

我曾尝试任何解决方案,我发现类似的问题对SO试图对准spinnerEditTxt强调。但是,没有帮助。如this post

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

感谢

+0

你有没有尝试将'android:baselineAligned =“false”'应用于'LinearLayout'? – azizbekian

回答

3

只是删除机器人:layout_marginBottom = “8DP” 从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

摆脱

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

,你将被罚款