本文介绍了如何在Android中更改EditText提示的字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如我在问题中提到的那样,我试图更改EditText中的提示字体.但我似乎无法实现!
As I have mentioned in the Question I am trying to change the font of hint in EditText. But I can't seem to make it happen!
这是我获取用户名的EditText的代码:
this is my code for the the EditText getting the username:
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:id="@+id/input_username_id"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="20dp">
<EditText
android:id="@+id/input_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:hint="@string/hint_username"
android:layout_marginRight="10dp"
android:gravity="right" />
</android.support.design.widget.TextInputLayout>
这是我的Java代码:
and here is my java code:
_usernameText = (EditText) (findViewById(R.id.input_username));
font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
_usernameText.setTypeface(font);
这并没有更改EditText提示的字体.我尝试了其他解决方案,但没有任何改变. http://chintanrathod.com/customizing-textinputlayout-part-2/
this didn't change the font of the hint of the EditText.I have tried other solutions and nothing changed.http://chintanrathod.com/customizing-textinputlayout-part-2/
推荐答案
不要
_usernameText = (EditText) (findViewById(R.id.input_username));
font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
_usernameText.setTypeface(font);
要做
TextInputLayout usernameTextObj = (TextInputLayout) findViewById(R.id.input_username_id));
font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
usernameTextObj .setTypeface(font);
这篇关于如何在Android中更改EditText提示的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!