Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set some views into TextInputLayout on Android

In my application i want show views into TextInputLayout.
I want show EditText, TextView (for show countDownTimer) and View (for show line)!

Such as Below Image :

My UI image

I write below codes, but i can show just EditText and i can't show any other views, such as TextView and View!

My XML codes :

<android.support.design.widget.TextInputLayout
    android:id="@+id/signInFrag_phoneInpLay"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginBottom="8dp"
    app:boxStrokeColor="@color/colorAccent"
    app:boxStrokeWidth="1dp">

    <EditText
        android:id="@+id/edtLogin1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:drawableEnd="@drawable/ic_phone"
        android:drawableRight="@drawable/ic_phone"
        android:gravity="right|center_vertical"
        android:hint="Phone Number"
        android:inputType="phone"
        android:maxLength="11"
        android:maxLines="1"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:singleLine="true"
        android:textColorHint="#c0c0c0"
        android:textSize="12sp" />

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

How can i change my code for show such as above image?

like image 259
Shambooli Avatar asked Sep 01 '25 10:09

Shambooli


1 Answers

You can set view as overlap on textInputLayout by constraintLayout. May be it has risk to overlap editText`s text with count text or vertical view. But i found in your text view has text limit. so For your reason it is not possible overlap the count text view.

Code **

 <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Search Page"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/input_layout"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:boxStrokeColor="@color/colorAccent"
        app:boxStrokeWidth="1dp"
        app:hintEnabled="true"
        app:layout_constraintTop_toBottomOf="@+id/title">

        <EditText
            android:id="@+id/edtLogin1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:drawableStart="@drawable/ic_action_profile"
            android:gravity="left|center_vertical"
            android:hint="Phone Number"
            android:inputType="phone"
            android:maxLength="11"
            android:maxLines="1"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:singleLine="true"
            android:textColorHint="#c0c0c0"
            android:textSize="12sp" />
    </com.google.android.material.textfield.TextInputLayout>

    <TextView
        android:id="@+id/text_view_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="22sec"
        app:layout_constraintBottom_toBottomOf="@+id/input_layout"
        app:layout_constraintEnd_toEndOf="@+id/input_layout"
        app:layout_constraintTop_toTopOf="@+id/input_layout" />

    <View
        android:id="@+id/view"
        android:layout_width="1dp"
        android:layout_height="0dp"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="4dp"
        android:background="@color/colorPrimary"
        app:layout_constraintBottom_toBottomOf="@+id/input_layout"
        app:layout_constraintEnd_toStartOf="@+id/text_view_time"
        app:layout_constraintTop_toTopOf="@+id/input_layout" />


</androidx.constraintlayout.widget.ConstraintLayout>
like image 92
Tariqul Islam Avatar answered Sep 02 '25 23:09

Tariqul Islam