项目
在 GitHub 查看 
meta/TextLayoutBuilder
关于
一个让文本布局构建更加便捷的 Android 库。
网站与应用开发可以做什么
- Create text Layouts easily.
- Reuse builders to create similarly styled Layouts.
- Cache Layouts of commonly used strings.
- Improve performance by warming up the FreeType cache.
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 0
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
TextLayoutBuilder
Build text Layouts easily on Android.
Features
- Create text
Layouts easily. - Reuse builders to create similarly styled
Layouts. - Cache
Layouts of commonly used strings. - Improve performance by warming up the FreeType cache.
Download
If using Gradle, add this to your build.gradle:
compile 'com.facebook.fbui.textlayoutbuilder:textlayoutbuilder:1.7.0'
or, if using Maven:
<dependency>
<groupId>com.facebook.fbui.textlayoutbuilder</groupId>
<artifactId>textlayoutbuilder</artifactId>
<version>1.7.0</version>
<type>aar</type>
</dependency>
Usage
- Set the properties on the
TextLayoutBuilder:
TextLayoutBuilder builder = new TextLayoutBuilder()
.setText("TextLayoutBuilder makes life easy")
.setTextColor(Color.BLUE)
.setWidth(400 /*, MEASURE_MODE_EXACTLY */);
- Call
build()on the builder to get aLayout:
Layout layout = builder.build();
- Use the
Layoutin your code:
public class CustomView extends View {
private Layout layout;
public CustomView(Context context) {
super(context);
}
public void setLayout(Layout layout) {
this.layout = layout;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// Draw the layout.
layout.draw(canvas);
}
}
Additional Usage
- Cache the layouts for commonly used strings by turning on caching in the
TextLayoutBuilder.
textLayoutBuilder.setShouldCacheLayout(true);
- Glyph warming provides significant performance boost for large blurbs of text.
Turn this on and pass in a
GlyphWarmerfor theTextLayoutBuilder.
textLayoutBuilder
.setShouldWarmText(true)
.setGlyphWarmer(new GlyphWarmerImpl());
- Import a style defined in XML into a
TextLayoutBuilderobject.
ResourceTextLayoutHelper.updateFromStyleResource(
textLayoutBuilder, // builder object
context, // Activity context
resId); // style resource id
License
TextLayoutBuilder is Apache-2-licensed.
探索相关项目
加载中…