Skip to content

mafshin/CustomTextView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

A CustomTextView class which removes the need for applying the custom fonts for each TextView

==============

Implementation:

  1. Under /res/values/ folder create attrs.xml file with the following cotents:

     <?xml version="1.0" encoding="utf-8"?>
    
     <declare-styleable name="CustomTextView">
     	<attr name="fontAssetName" format="string"/>
     </declare-styleable>
    
  2. Add your desired fonts in /assets folder like "Politica XT.otf" font

==============

Usage:

Simply set the fontAssetName attribute to an EXISITING font file name in your assets folder

<?xml version="1.0" encoding="utf-8"?>

<com.my.app.CustomTextView
        xmlns:custom="http://schemas.android.com/apk/res/com.my.app"            
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test text"
        android:id="@+id/testcustomview" 
        
        custom:fontAssetName="Politica XT.otf"
        />
<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back"
        android:id="@+id/button"/>

About

CustomTextView

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages