Reputation: 516
I try to set the keyboard type of an edit text.
When I use below code, it changes the font of the edit text's hint.
setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
So, I try another solution.
setTransformationMethod(new PasswordTransformationMethod());
I create an edit text. My password is shown on top of the keyboard.(looks like auto suggestion).
How can I set the keyboard type for password without changing the font of the text?
Upvotes: 1
Views: 5088
Reputation: 1720
// this work for me, donot set android:inputType="textPassword" in your xml file and instead, set it in java
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
editText.setTransformationMethod(new PasswordTransformationMethod());
Upvotes: -1
Reputation: 516
Solution is here:
typeface = edittext.getTypeface();
editText.setInputType(InputType.TYPE_CLASS_TEXT |InputType.TYPE_TEXT_VARIATION_PASSWORD);
editText.setTypeface(typeface);
Upvotes: 2
Reputation: 869
for Font issue you can try this :
editText.setInputType(InputType.TYPE_CLASS_TEXT |InputType.TYPE_TEXT_VARIATION_PASSWORD);
editText.setTypeface(Typeface.DEFAULT);
Upvotes: 4