0

I am currently learning some design on XML. I have a scroll view and I have Several widgets. However, I want to remove space between my Log In and my password, how can I combine them together yet be able to input email and password?

What I want :

enter image description here

what I currently have

enter image description here

Thanks for the help.

So below is my simple code. How can I remove space and have them come together?

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="0dp">

    <EditText
        android:id="@+id/email"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="@color/white"
        android:hint="Email"
        android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>

<!--  Password Label -->
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="8dp">

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="38dp"
        android:background="@color/white"
        android:hint="Password"
        android:inputType="textPassword"
        android:textColorHint="@color/black" />
</android.support.design.widget.TextInputLayout>
Misha Akopov
  • 12,241
  • 27
  • 68
  • 82

4 Answers4

0

You can remove extra top spacing by setting app:hintEnabled="false" to TextInputLayout:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    app:hintEnabled="false"
    android:layout_marginBottom="0dp">

.....

It is space left for hint

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
0

Try changing the top/bottom margins of the EditText widgets. Like so:

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="0dp">

<EditText
    android:id="@+id/email"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@color/white"
    android:hint="Email"
    android:inputType="textEmailAddress"

    android:layout_marginBottom="0dp"
/>

</android.support.design.widget.TextInputLayout>

<!--  Password Label -->
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="8dp">

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="38dp"
        android:background="@color/white"
        android:hint="Password"
        android:inputType="textPassword"
        android:textColorHint="@color/black"

        android:layout_marginTop="0dp" 
/>
</android.support.design.widget.TextInputLayout>

I would also experiment with the android:padding attribute.

More info: Difference between a View's Padding and Margin

nromano
  • 56
  • 1
  • 4
0

You can put login view and password view into linear layout, and margin_top and margin_bottom = 0

Tung Tran
  • 2,885
  • 2
  • 17
  • 24
0

It's not about space between views, it's about view style. So search for style you need your EditText appears

Something like this tutorial

Safa
  • 473
  • 5
  • 22