Author's weibo: @攻城师sloop
Android FontsManager, It can help you change the module font easily.
//sloop's maven
maven {url "http://dl.bintray.com/gcssloop/maven"}
Example:
allprojects {
repositories {
jcenter()
//sloop's maven
maven {url "http://dl.bintray.com/gcssloop/maven"}
}
}
//fontsmanager
compile 'com.sloop.view.fonts:fontsmanager:1.2.3'
Example:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
//fontsmanager
compile 'com.sloop.view.fonts:fontsmanager:1.2.3'
}
You can use any of the following four methods to initialize the FontManager.
// NO.1
FontsManager.init(typeface); // use typeface
// NO.2
FontsManager.initFormAssets(context, fontPath); // use context and path(file in Assets)
// NO.3
FontsManager.initFormFile(fontFile); // use font file in sdcard
// NO.4
FontsManager.initFormFile(fontFilePath); // use font filePath in sdcard
FontsManager.changeFonts(activity);
FontsManager.changeFonts(view);
FontsManager.changeFonts(viewGroup);
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FontsManager.initFormAssets(this, "fonts/sao.ttf"); //initialization
FontsManager.changeFonts(this); //Change Activity font
}
Version | Notes |
---|---|
v1.2.3 | Fix a bug with ActionBar |
v1.2.2 | Fix a bug with ActionBar |
v1.2.1 | Support Gradle build, Logic Optimization |
v1.2.0 | Support change ActionBar fonts |
v1.0.1 | Fix error log |
v1.0.0 | Support change View ViewGroup Activity's font |
Copyright (c) 2015 GcsSloop
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.