Android EditText for password with android:hint

前端 未结 9 1107
清歌不尽
清歌不尽 2020-12-13 03:21

Just noticed that android:password has been deprecated, and we should be using android:inputType. Was experimenting with it by setting in my xml

         


        
相关标签:
9条回答
  • 2020-12-13 03:58

    Actually, I found that if you put the the android:gravity="center" at the end of your xml line, the hint text shows up fine with the android:inputType="textVisiblePassword"

    0 讨论(0)
  • 2020-12-13 04:00

    Here is your answer:

    There are different category for inputType so I used for pssword is textPaswword

    <EditText
        android:inputType="textPassword"
        android:id="@+id/passwor"
        android:textColorHint="#ffffff"
        android:layout_marginRight="15dp"
        android:layout_marginLeft="15dp"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:hint="********"
        />
    
    0 讨论(0)
  • 2020-12-13 04:02

    I had the same issue and found a solution :

    Previous code:

        <EditText 
        android:layout_height="wrap_content"
        android:gravity="center" 
        android:inputType ="password" 
        android:layout_width="fill_parent"
        android:id="@+id/password" 
        android:hint="password" 
        android:maxLines="1">
        </EditText>
    

    Solution:

    <EditText 
    android:layout_height="wrap_content"
    android:gravity="center" 
    android:password="true" 
    android:layout_width="fill_parent"
    android:id="@+id/password" 
    android:hint="password" 
    android:maxLines="1">
    </EditText>
    

    The previous code does not show the 'hint', but when I changed it to the last one it started showing...

    hope this be helpful to someone...

    0 讨论(0)
  • 2020-12-13 04:07

    Here is your answer. We can use both simultaniously. As i used both and they are working fine. The code is as follows:

    <EditText
        android:id="@+id/edittext_password_la"
        android:layout_below="@+id/edittext_username_la"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dip"
        android:inputType="textPassword"
        android:hint="@string/string_password" />
    

    This will help you.

    0 讨论(0)
  • 2020-12-13 04:07

    android:hint="Enter your question" or something like this must work. I am using Relative layout with EditText as If you want to use password,say android:inputType="textPassword" for hiding characters and "textVisiblePassword" for showing what you enter as password.

    0 讨论(0)
  • 2020-12-13 04:10

    Hint text not bold, I try to below code.

    When I change inputtype=email, other edittext is bold. But when I change input type to password, hint is normal.

    I need hint text to be bold, my code is:

     <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="56dp"
                app:theme="@style/Widget.Design.TextInputLayout"
                >
                    <EditText
                        android:id="@+id/login_password"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Password"
                        android:textStyle="bold"
                        android:inputType="textPassword"
                        android:textColor="@color/White"
                        style="@style/Base.TextAppearance.AppCompat.Small"
                        android:drawableLeft="@drawable/ic_password"
                        android:drawablePadding="10dp"
                        />
                </android.support.design.widget.TextInputLayout>
    
    0 讨论(0)
提交回复
热议问题