當我在我的EditText中設置inputType=textPassword
時,hint
的文本樣式發生了變化。請參閱本圖片:如何在inputType設置爲textPassword的情況下爲EditText提供樣式提示
兩個EditTexts具有相同的XML但上有inputType
設置爲textPassword
。
我該如何讓它們看起來一樣?
當我在我的EditText中設置inputType=textPassword
時,hint
的文本樣式發生了變化。請參閱本圖片:如何在inputType設置爲textPassword的情況下爲EditText提供樣式提示
兩個EditTexts具有相同的XML但上有inputType
設置爲textPassword
。
我該如何讓它們看起來一樣?
設置EDITTEXT字樣默認編程
password.setTypeface(Typeface.DEFAULT);
問題是文本setTypeface。
提示:在默認情況下,當你設置一個EditText元素使用 「textPassword」輸入類型,字體系列設置爲等寬,所以你 應其字體系列變更爲「無襯線」,所以兩個文本字段 都使用匹配的字體樣式。
欲瞭解更多詳細信息,請參閱此鏈接, Try
在EditText上的inputType設置爲textPassword字體會改變 使用TextInputLayout的EditText上密碼字段
試試這個代碼:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintEnabled="false"
app:passwordToggleEnabled="true">
<EditText
android:id="@+id/input_password"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:drawableLeft="@drawable/ic_password"
android:drawableStart="@drawable/ic_password"
android:hint="@string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:textColor="@color/floating_text_color_accent"
android:textSize="@dimen/text_size_small" />
</android.support.design.widget.TextInputLayout>
可能重複[Android:字體改變時,我應用密碼鍵入EditText](https://stackoverflow.com/questions/24117178/Android的字體-IS-改變-時-I-應用密碼型上的EditText) –