2017-06-16 48 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" 

,你將被罰款