简体   繁体   中英

How to change the position of toggle button in TEXTINPUTLAYOUT?

Hey I'm working with material design dependency and having a problem that how I change the position of toggle button in TEXTINPUTLAYOUT ? As seen in below image the word password is not align with password toggle button

Thanks

    <com.google.android.material.textfield.TextInputLayout
    android:id="@+id/tiet_s_pwd"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:gravity="center_vertical"
    app:boxBackgroundMode="outline"
    app:boxStrokeColor="@color/white"
    app:boxStrokeErrorColor="@color/white"
    app:boxStrokeWidth="0dp"
    app:errorEnabled="true"
    app:errorTextColor="@color/primarydark"
    app:hintEnabled="false"
    app:passwordToggleEnabled="true"
    app:passwordToggleTint="#3030"
    app:layout_constraintBottom_toBottomOf="@+id/hguide_s_12"
    app:layout_constraintEnd_toEndOf="@+id/vguide_s_4"
    app:layout_constraintStart_toStartOf="@+id/vguide_s_1"
    app:layout_constraintTop_toTopOf="@+id/hguide_s_10">


    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/transparent"
        android:hint="Password"
        android:inputType="textPassword"
        android:paddingLeft="@dimen/text"
        android:paddingRight="@dimen/text"
        android:paddingBottom="@dimen/pb"
        android:textColor="#303030"
        android:textColorHint="#50303030"
        android:textSize="@dimen/text" />
</com.google.android.material.textfield.TextInputLayout>

在此处输入图像描述

For normal setup the toggle button will be aligned center. I think it is caused by the padding setting?

Try to remove or adjust your padding of your TextInputEditText :

android:paddingLeft="@dimen/text"
android:paddingRight="@dimen/text"
android:paddingBottom="@dimen/pb"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM