TextLayoutBuilder


Source link: https://github.com/facebookincubator/TextLayoutBuilder

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.1.0'

or, if using Maven:

<dependency>
<groupId>com.facebook.fbui.textlayoutbuilder</groupId>
<artifactId>textlayoutbuilder</artifactId>
<version>1.1.0</version>
<type>aar</type> </dependency>

Usage

  1. Set the properties on the TextLayoutBuilder:
TextLayoutBuilder builder = new TextLayoutBuilder()
  .setTextAppearance(context, resId)
  .setText("TextLayoutBuilder makes life easy")
  .setWidth(400 /*, MEASURE_MODE_EXACTLY */);
  1. Call build() on the builder to get a Layout:
Layout layout = builder.build();
  1. Use the Layout in your code:
public class CustomView extends View {

  private Layout mLayout;

public CustomView(Context context, AttributeSet attrs) {

super(context, attrs);

  
}

public void setLayout(Layout layout) {

mLayout = layout;
  
}

@Override
  protected void onDraw(Canvas canvas) {

super.onDraw(canvas);

 // Draw the layout.

mLayout.draw(canvas);

  
}
 
}

Additional Usage

  1. Cache the layouts for commonly used strings by turning on caching in the TextLayoutBuilder.
mTextLayoutBuilder.setShouldCacheLayout(true);
  1. Glyph warming provides significant performance boost for large blurbs of text. Turn this on and pass in a GlyphWarmer for the TextLayoutBuilder.
mTextLayoutBuilder
  .setShouldWarmText(true)
  .setGlyphWarmer(new GlyphWarmerImpl());
  1. Import a style defined in XML into a TextLayoutBuilder object.
ResourceTextLayoutHelper.updateFromStyleResource(
  mTextLayoutBuilder, // builder object
  mContext,

  // Activity context
  resId);

 // style resource id

Resources

ActivitySwitcher is based on the Activity view operation management library, you can achieve any jump between Activity, close any Activity and end applications and other functions.

Simplify Android permission with in-build message Dialogs.

Features:

  • InBuild Rational Dialog with custom message
  • InBuild SettingScreen Dialog with custom Message.
  • Callback for permission state:
    • Permission granted
    • Permission removed
    • Permission access removed.

This is the SampleApp for Android Project Structure.

A simple audio player for Android that you can plugin to your apps quickly get audio playback working.

Android screen or view recorder.

A easy and simple library to apply Gaussian blur on images.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes