Mahabub Karim
Mahabub Karim

Reputation: 870

How to create Gmail like edittext Layout

Need a layout like this layout I need layout like this, is there any google api for this layout

Upvotes: 2

Views: 2515

Answers (2)

NAP-Developer
NAP-Developer

Reputation: 3796

Support New Library

implementation 'com.google.android.material:material:1.1.0'

Upvotes: 0

Srikar Reddy
Srikar Reddy

Reputation: 3708

You have to add the style style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" to TextInputLayout

If you have moved away from the android support library and are currently using Material Design Components.

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/emailTextInputLayout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/edit_text_horizontal_margin"
    android:layout_marginEnd="@dimen/edit_text_horizontal_margin"
    android:layout_marginBottom="@dimen/edit_text_vertical_margin"
    android:hint="Username"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/emailTextInputEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" />

</com.google.android.material.textfield.TextInputLayout>

If not, I suggest you to read the article I have written on how to migrate to Material Design Components.

Old Answer:

Eg:

<android.support.design.widget.TextInputLayout
    android:id="@+id/emailTextInputLayout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/edit_text_horizontal_margin"
    android:layout_marginEnd="@dimen/edit_text_horizontal_margin"
    android:layout_marginBottom="@dimen/edit_text_vertical_margin"
    android:hint="Username"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/emailTextInputEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" />

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

Upvotes: 4

Related Questions