Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show Password icon in TextInputLayout touching the base line

I had some problem with my show password icon in TextInputLayout with android:inputType="textPassword". Right now it is showing like this enter image description here

As you can see the show password icon is touching the base line. I want something like thisenter image description here

You can see the gap between them.

The xml sode for implementing TextInputLayout is given below:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/TextLabelSNA"
    app:layout_constraintTop_toBottomOf="@+id/mailSave"
    app:layout_constraintBottom_toBottomOf="parent"
    android:layout_marginBottom="16dp"
    android:layout_marginTop="16dp"
    android:layout_marginStart="16dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginLeft="16dp"
    android:layout_marginEnd="16dp"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginRight="16dp"
    android:id="@+id/tilOp"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintVertical_bias="0.0">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:inputType="textPassword"
        android:hint="Old Password"
        android:ems="10"
        android:textColor="#0A0B12"
        android:id="@+id/oldPassword"/>
</android.support.design.widget.TextInputLayout>

style used is:

<style name="TextLabelSNA" parent="Widget.Design.TextInputLayout">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/hintBlack</item>
    <item name="android:textSize">16sp</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/hintBlack</item>
    <item name="colorControlNormal">@color/hintBlack</item>
    <item name="colorControlActivated">@color/hintBlack</item>
</style>

Please Help..!!!

like image 340
Rahul Sharma Avatar asked Oct 05 '16 07:10

Rahul Sharma


People also ask

How did the developer hide the input by dots in the password EditText?

change the edittext input type property to text password in xml. Show activity on this post. As the original poster mentioned in a comment, calling setSingleLine (boolean singleLine) resets the EditText settings, so you'll have to call that first and after that set custom settings like the password InputType .

How do I get rid of TextInputLayout padding?

You can remove extra space above AppCompatEditText by setting app:hintEnabled="false" to TextInputLayout but it won't display hint until you re-enable that.


2 Answers

just add app:passwordToggleEnabled="true" in your textinputlayout

<android.support.design.widget.TextInputLayout
            app:layout_widthPercent="90%"
            android:layout_height="wrap_content"
            android:hint="@string/password"
            android:textColorHint="@android:color/white"
            app:passwordToggleEnabled="true"
            app:passwordToggleTint="@android:color/white">

            <android.support.v7.widget.AppCompatEditText
                android:id="@+id/et_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:textColor="@android:color/white"
                android:visibility="gone"
                 />


        </android.support.design.widget.TextInputLayout>
like image 158
dieter115 Avatar answered Sep 21 '22 15:09

dieter115


  <android.support.design.widget.TextInputLayout
        android:id="@+id/inputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:passwordToggleEnabled="true">
        <EditText
            android:id="@+id/txtpwd"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:drawableLeft="@drawable/lock"
            android:ems="10"
            android:hint="  Password"
            android:imeOptions="actionGo"
            android:inputType="textPassword"
            android:padding="10dp">

        </EditText>
    </android.support.design.widget.TextInputLayout>
like image 37
RajGanesh Avatar answered Sep 22 '22 15:09

RajGanesh