Custom view inflated in code doesn't get custom font
See original GitHub issueI have a custom view with TextViews. Those TextViews have a custom font. If I include an instance of my custom view in XML as part of an activity the custom font will render correctly.
However, if I dynamically create an instance of my custom view the custom font is not applied.
CustomView customView = new CustomView(context);
this.addView(customView);
Inside of my custom view I am inflating the XML:
LayoutInflater.from(context).inflate(R.layout.custom_view, this, true);
As I say, it works correctly unless I create the view dynamically at runtime. Is this a genuine issue or am I overlooking something?
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Create a custom View by inflating a layout? - Stack Overflow
What you want to do is create a Compound Control. You'll create a subclass of RelativeLayout, add all our your components in code...
Read more >The beauty of Custom Views in Android and How to do it!
You will learn how to inflate a custom layout for your view and pass two different parameters. It's quick and easy! The code...
Read more >Creating a Custom View in Android
What are Custom Views? ... A custom view is a view that you design in any way you want by extending another view...
Read more >Dialogs - Android Developers
You can accomplish a wide variety of dialog designs—including custom layouts and those described in the Dialogs design guide—by extending ...
Read more >Writing a Custom Android View - Conjure
This article will demonstrate the different ways you can create a custom Android View and provide guidance on when to use each approach....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, that would make perfect sense. There should be a lint check for that.
On Fri, 1 Apr 2016, 16:57 Tarekk Mohamed Abdalla, notifications@github.com wrote:
I had this issue if i set the
Context
togetApplicationContext()
. But I fixed it withthis
as context