I am trying to create a layout like in the picture below
In the above picture the password field is in the TextInputLayout and it also have a TextView in the right side , which points to the Forget Password Activity.
I achive EditText with Textview without TextInpt layout like below using relative layout
XML layout:
<EditText
android:id="@+id/email_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_email"
android:drawableStart="@drawable/ic_email"
android:drawablePadding="10dp"
android:hint="@string/email_address"
android:textSize="14sp"
android:maxLines="1"
android:inputType="textEmailAddress" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/etxt_password_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_password"
android:drawableStart="@drawable/ic_password"
android:drawablePadding="10dp"
android:textSize="14sp"
android:hint="Password"
android:layout_alignParentLeft="true"
android:inputType="textPassword"
android:maxLines="1"/>
<TextView
android:id="@+id/txt_forget_password"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="forget ?"
android:textSize="12sp"
android:layout_marginRight="10dp"
android:textColor="#808080"
/>
</RelativeLayout>
But If I add TextInputLayout in the EditText I can't achieve it.
How I resolve this issue?
Just use: TextInputLayout textInputLayout = findViewById(R. id. custom_end_icon); String text = textInputLayout.
TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.
Now you can simply do input. setError(..) for new error and input. setErrorEnabled(false) to remove it.
I am trying like below and it is working for me. may be it may help you. Somehow I am unable to use TextView inside TextInputLayout, layout getting crash. But i am able to use ImageViews inside it.
<android.support.design.widget.TextInputLayout
android:id="@+id/layoutTextInput"
style="@style/CommonTextInputLayout"
android:textColorHint="@color/aluminium">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/editTextValue"
style="@style/CommonEditText"
android:imeOptions="actionNext"
android:layout_marginBottom="8dp"
android:inputType="text"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-40dp"
android:src="@drawable/ic_tick_green"/>
</LinearLayout>
</android.support.design.widget.TextInputLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With