Customizing TextInputLayout – Part 2

TextInputLayout Demo

In previous article Customizing TextInputLayout – Part 1, we learnt how to customize TextInputLayout and how to apply hint color to it.

Going to next step of TextInputLayout, in this article we are going to customize this widget by applying custom Typeface to it.

Change Typeface of TextInputLayout

First what you need to do is, download some decent fonts online. You can also use fonts which I have used in demo by downloading it from here.

After downloading fonts, open your file. Actually there is no any method to apply custom fonts in XMl layout file. So we need to patch some part of TextInputLayout to apply custom font.

Declare objects and assign ids to them. Here, in my demo, I took 3 TextInputLayout and apply ids like below.

In your activity, code will be like

After declaring objects, you need to write following method inside your activity. Copy paste below code.

All things are done to apply Typeface to TextInputLayout. We have objects, we have typeface files and we have method to apply font. So simply write below single line of code to apply font to TextInputLayout.






The source code for this article is available here


In this article, we learnt how to apply custom Typeface to TextInputLayout. You can apply any Typeface to as per your need.

You may also like to read

Customizing TextInputLayout – Part 1 In previous article TextInputLayout – Material Design Support library Tutorial, we learn what is TextInputLayout and what is functionality of it. How ...
Auto Restart application after Crash/Force Close i... In an Android application, we usually got the "Force Closed" error if we didn't get the exceptions right. Everyone has question about "How can I resta...
Develop apps faster using Data Binding – Par... Google has been pushing updates to existing tools and making the life of android developers easier. They also have been releasing new libraries and AP...
Read Logs programmatically in Android In this blog you will learn how to read logs programmatically in Android and used for bug report purposes. Its easy to read logs from Logcat an...
Share on Facebook4Share on Google+1Tweet about this on TwitterShare on LinkedIn1Share on Reddit0Pin on Pinterest0Share on Tumblr0Email this to someone