Underline below counter is not the same as EditText Underline

I have read posts on SO and none of the solutions solved my problem. I'm using style="@style/Base.Widget.AppCompat.Spinner.Underlined

to add underscore to Spinner

, but for somereason the baseline

counter doesn't align with EditText

. here is my 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>

      

Here's the result:

enter image description here

I have tried any solution I found for similar problems on SO trying to align underscore Spinner

with EditTxt

. However, it didn't help. for example this post .

I am looking for a solution or workaround for this problem.

thank

+3


source to share


2 answers


Just remove android: layout_marginBottom = "8dp" from your 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>

      



+3


source


Get rid of

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

      



and you will be fine

+1


source







All Articles