2017-01-12 9 views
1

지원 라이브러리의 새 기능인 TextInputLayout을 사용하고 있습니다 : passwordToggleEnabled. 이렇게하면 사용자가 암호 표시 여부를 전환 할 수있는 멋진 "눈"을 제공합니다.TextInputLayouts로 표시된 비밀번호 passwordToggleEnabled

제 질문은이 기능을 사용하는 방법이 있지만 암호가 표시된 상태에서 시작하는 것입니까?

내 XML : 나는 XML에서이 작업을 수행하는 방법, 그리고 수동으로 이후의 가시성을 전환 할 수있는 방법을 발견하지 않았습니다 enter image description here

:

<android.support.design.widget.TextInputLayout 
        android:id="@+id/password" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        app:passwordToggleEnabled="true"> 

        <EditText 
         android:id="@+id/password_edit" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:hint="@string/prompt_password" 
         android:inputType="textPassword" /> 
</android.support.design.widget.TextInputLayout> 

토글이 비슷합니다 보기가 렌더링됩니다. EditText의 입력 유형을 textVisiblePassword로 설정하면 토글이 표시되지 않습니다. 예를 들어 mPasswordEditText.setTransformationMethod (null); 암호는 표시되지만 토글은 사라지고 사용자는 암호를 다시 숨길 수 없습니다. 내가 수동으로 모든 것을 할 수 있습니다 알고 있지만 나는 그것이

+0

이 답변을 확인할 수 있습니다. http://stackoverflow.com/a/27050480/7329597 희망이 있습니다. :) –

+0

이 답변을 확인하십시오 http://stackoverflow.com/a/27050480/7329597 희망이 있습니다. . :) –

+0

@SejalBell - 수동으로 암호를 표시하거나 숨기는 것입니다. TextInputLayouts 새로운 자동 토글에서는 작동하지 않습니다. 대답 유형에서 입력 유형을 보이는 비밀번호로 설정하면 토글 버튼이 사라집니다. 비밀번호를 기본값으로 표시하고 싶지만 사용자가 비밀번호를 다시 숨길 수 있습니다. – Gober

답변

0

사용할 수있는 새로운 마법 전환 작업을 할 수 있는지 궁금 :

yourEditText.setTransformationMethod(new PasswordTransformationMethod()); 

가 읽기 가능한 암호를 다시 표시, 단지 변화로 null을 전달합니다 방법 :

yourEditText.setTransformationMethod(null); 

사용자가 다시 숨길 수 있습니다.

+0

답해 주셔서 감사합니다. 그러나 이것도 토글 버튼을 사라지게합니다. 나는 작동하지 않는 것이 무엇인지 분명히하기 위해 나의 질문을 확장했다. – Gober