Many a times we are fed up to set different fonts to each element of the activity,so Global Font Library provides simplest way to set any Custom Font to any of the view throughout the Application.
Simple Views | Spinner |
---|---|
##Download GlobalFonts.jar add jar to libs/
add following lines in build.gradle (app module)
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/GlobalFonts.jar')
}
##Add Fonts
Add your custom fonts to assets/
RelativeLayout root = (RelativeLayout)findViewById(R.id.root);
GlobalFonts.setFontstoAllViews(this,root,"Linotype - DINNextLTPro-UltraLight.otf", Color.BLACK);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner=(Spinner)findViewById(R.id.s);
String items[]={"Global","Fonts"};
s.setAdapter(new GlobalFontsForSpinner(this,
R.layout.support_simple_spinner_dropdown_item,
items,"Linotype - DINNextLTPro-UltraLight.otf"));
Set Font to any CheckBox or Radio Button or Switch or Toggle Button just pass following Arguments in order :
- context (Activity)
- View Id (int)
- font-name (String)
- color (int)