Comments (9)
I'd be also interested in this.
from calligraphy.
We did something similar in our app using custom text appearance styles. Not exactly what you want, but works well enough.
from calligraphy.
We did something similar in our app using custom text appearance styles. Not exactly what you want, but works well enough.
@masterjefferson May I have the custom view/class?
from calligraphy.
@MHKalantarian How did you solved this issue?
from calligraphy.
@basmaessen Custom class for every single view and not binding calligraphy on some pages!
from calligraphy.
@MHKalantarian And what if you have multiple fonts for 1 view
from calligraphy.
@basmaessen If you mean multiple fonts for 1 type of view you'll have to use a custom attribute or get the font in constructor
but if you mean multiple fonts for 1 textfield
Multiple Typeface's per TextView / Spannables
It is possible to use multiple Typefaces inside a TextView, this isn't new concept to Android.This could be achieved using something like the following code.
SpannableStringBuilder sBuilder = new SpannableStringBuilder();
sBuilder.append("Hello!") // Bold this
.append("I use Calligraphy"); // Default TextView font.
// Create the Typeface you want to apply to certain text
CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/Roboto-Bold.ttf"));
// Apply typeface to the Spannable 0 - 6 "Hello!" This can of course by dynamic.
sBuilder.setSpan(typefaceSpan, 0, 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
setText(sBuilder, TextView.BufferType.SPANNABLE);
from calligraphy.
@MHKalantarian Do you have an example of a custom view for a TextView or Button or something?
from calligraphy.
@basmaessen a simple example for a textview
public class TextViewWithFont extends TextView {
public TextViewWithFont(Context context, AttributeSet attrs) {
super(context, attrs);
this.setTypeface(exampleTypeFace);
}
public TextViewWithFont(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.setTypeface(exampleTypeFace);
}
public TextViewWithFont(Context context) {
super(context);
this.setTypeface(exampleTypeFace);
}
}
from calligraphy.
Related Issues (20)
- Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdReceiver HOT 3
- Jumping toolbar titles HOT 2
- android.view.inflateException HOT 5
- Calligraphy not functioning on API 21 HOT 1
- This will affect the recyclerView items HOT 1
- Font not getting applied to PopupMenus or the BottomNavigationView HOT 5
- Calligraphy with CompileSDKVersion = 29 HOT 5
- Apply custom font at run-time downloaded from WebServer. HOT 2
- Font not applied to Material Design NavigationView menu items HOT 2
- I get android.content.res.Resources$NotFoundException. How can I solve this? HOT 4
- androidx.appcompat.widget.FitWindowsLinearLayout HOT 5
- font for whole app not working HOT 1
- ViewPumpContextWrapper is final HOT 1
- CalligraphyConfig().Builder issue HOT 1
- Add Support for Google Downloadable Fonts? HOT 3
- Proguard configuration not working HOT 1
- fontPath attribute not working with DialogFragment HOT 1
- Toast HOT 1
- ViewPump shows deprecation error. HOT 3
- Toolbar's subtitle is cleared if subtitle set programmatically
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calligraphy.