I have a custom view which contains several RobotoTextViews and I want to set typefaces for them. So, I use declare-styleable item like this:
<declare-styleable name="CustomView">
<attr name="firstTextviewStyle" format="reference" />
<attr name="secondTextviewStyle" format="reference" />
</declare-styleable>
The attributes are referenced to styles.
<style name="firstTextAppearance">
<item name="typeface">roboto_medium</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@android:color/white</item>
</style>
So, question is, how to get typeface attr value from this?
@nullpex you can do something like this for dynamic or runtime font change in your app like the following example. You can also use it in your layout file cuz there is custom view also with custom attributes.
I have created a repository for the following code on GitHub https://github.com/harsh159357/customtextview
Feel free to ask any question
CustomTextViewActivity.java
activity_text_view.xml
CustomTextView.java
attrs.xml
styles.xml
strings.xml