Someone tried to change the font of the floating label? I changed the source of EditText but the font of the floating label did not change, I am very grateful to those who help me
Code:
<android.support.design.widget.TextInputLayout
android:id="@+id/tilTextoDescricao"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tilValorUnidade"
android:layout_marginTop="10dp">
<EditText
android:id="@+id/etTextoDescricao"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:hint="Descrição"
android:textSize="15dp"
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
-----------------
etTextoDescricao= (EditText) findViewById(R.id.etTextoDescricao);
etTextoDescricao.setTypeface(CustomTypeface.getTypefaceMediumDefault(this));
This is how i achieve this
i just found a simple solution and it's worked for me:
in this way you can set the typeface to hint of any edit text:
in layout.xml :
and in java class :
fixing a problem in @adneal answer: if setErrorEnabled is not set true, mErrorView would be null and if you set it false at any point the font would change back to default. so to fix it:
in you custom TextInputLayout override setErrorEnabled
There is a simpler way,
Create a new directory in your 'res' folder named 'font' and put a font in there. Then open your 'styles' file and create a new style :
You can add more properties as well, such as textColor, textSize etc..
Then in your XML:
I checked it and it works.
I'm using new
MaterialComponents
theme and none of the answers helped me.Had to play with styles and themes on my own. Will post a chunk of styles here in case somebody faces the same issue.
Then in xml layout:
Here's the result:
Here is a custom class implementation for adneal's answer.
In your XML files now you need to use
CustomTextInputLayout
instead ofTextInputLayout
and it will work out of the box.Thanks adneal for the answer.