【问题标题】:How to change the position of toggle button in TEXTINPUTLAYOUT?如何更改 TEXTINPUTLAYOUT 中切换按钮的位置?
【发布时间】:2020-12-28 03:02:26
【问题描述】:

嘿,我正在处理材料设计依赖问题,并且遇到了一个问题,如何更改 TEXTINPUTLAYOUT 中切换按钮的位置?如下图所示,单词 password密码切换按钮

不一致

谢谢

    <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>

【问题讨论】:

  • 嗨,欢迎来到 StackOverflow。没有任何迹象表明您尝试了什么以及您期望发生什么,很难猜测其他人可以分享哪些知识来帮助您,除了显而易见的阅读文档(如果您没有这样做,这实际上是一个很好的建议) )。在提问之前考虑阅读this
  • 你试图解决什么?请考虑上传代码。
  • @ShoaibKhalid 这不需要代码;它需要的是一个清晰的解释。 HEET:您指的是密码切换吗?

标签: android android-textinputlayout textinputlayout


【解决方案1】:

对于正常设置,切换按钮将居中对齐。我认为这是由padding 设置引起的?

尝试删除或调整您的padding 或您的TextInputEditText

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-14
    • 1970-01-01
    • 2015-10-22
    • 2013-04-10
    • 2019-01-19
    • 2017-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多