facebook / textlayoutbuilder Goto Github PK
View Code? Open in Web Editor NEWAn Android library that allows you to build text layouts more easily.
Home Page: https://facebook.github.io/TextLayoutBuilder
License: Apache License 2.0
An Android library that allows you to build text layouts more easily.
Home Page: https://facebook.github.io/TextLayoutBuilder
License: Apache License 2.0
while (true) {
try {
layout = StaticLayoutHelper.make(
mParams.text,
0,
mParams.text.length(),
mParams.paint,
width,
mParams.alignment,
mParams.spacingMult,
mParams.spacingAdd,
mParams.includePadding,
mParams.ellipsize,
width,
numLines,
mParams.textDirection);
} catch (IndexOutOfBoundsException e) {
// Workaround for https://code.google.com/p/android/issues/detail?id=35412
if (!(mParams.text instanceof String)) {
// remove all Spannables and re-try
Log.e("TextLayoutBuilder", "Hit bug #35412, retrying with Spannables removed", e);
mParams.text = mParams.text.toString();
continue;
} else {
// If it still happens with all Spannables removed we'll bubble the exception up
throw e;
}
}
break;
}
Hello!
Maybe this is intentional but.. did someone forget to upload version 1.3.1?
The readme, the website and the commits say the latest version is 1.3.1, but I get Failed to resolve: com.facebook.fbui.textlayoutbuilder:textlayoutbuilder:1.3.1
when I try to sync my project.
Thanks!
New in Android API 23: https://developer.android.com/reference/android/text/StaticLayout.Builder.html#setBreakStrategy(int)
Would be nice to have an API for it!
H
I can see this project is being used in Litho as well. From there, I came searching here for letter spacing support as it is in Android TextView.
Are there any plans to this in future?
In GlyphWarmerImpl, the textlayout is drawn to a Picture on separate thread, however it seems this Picture is not used, and not drawn on the real view?
Is code like the below thread safe?
Layout layout = new TextLayoutBuilder()
.setTextAppearance(context, resId)
.setText("TextLayoutBuilder makes life easy")
.setWidth(400)
.layout();
My understanding is that Litho does background layout and measurement. And Litho uses TextLayoutHelper under the hood for some things. So I'm wondering if this library can be used to write a custom view that does all its measurement and layout on a background thread (assuming I already know max size).
With textview, we can use clickable span by setMovementMethod.
How can we use it in custom view with staticLayout?
the constructor method with 'int maxLines' param is a hide method.
Does StaticLayoutProxy.java can new StaticLayout object with the 'maxLines' directly?
/**
* @hide
*/
public StaticLayout(CharSequence source, int bufstart, int bufend,
TextPaint paint, int outerwidth,
Alignment align, TextDirectionHeuristic textDir,
float spacingmult, float spacingadd,
boolean includepad,
TextUtils.TruncateAt ellipsize, int ellipsizedWidth, int maxLines) {
When you create the layout you try to handle the different scenario. Each of case happens of the specific version of API?
in usage 3
it is wrong that the first line of the method of onDraw ?
it has a error of java.lang.StackOverflowError.
it should be super.onDraw(canvas);
#3: Linking greylist-max-p Landroid/text/StaticLayout;->(Ljava/lang/CharSequence;IILandroid/text/TextPaint;ILandroid/text/Layout$Alignment;Landroid/text/TextDirectionHeuristic;FFZLandroid/text/TextUtils$TruncateAt;II)V use(s):
Lcom/facebook/fbui/textlayoutbuilder/proxy/StaticLayoutProxy;->create(Ljava/lang/CharSequence;IILandroid/text/TextPaint;ILandroid/text/Layout$Alignment;FFZLandroid/text/TextUtils$TruncateAt;IILandroidx/core/text/TextDirectionHeuristicCompat;)Landroid/text/StaticLayout; (2 occurrences)
the constructor method is Deprecated, should be instead of Builder.
Continuing from facebook/litho#284, the issue stems from TextLayoutBuilder itself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.