public class

StaticLayoutTextView

extends View
java.lang.Object
   ↳ android.view.View
     ↳ com.sap.cloud.mobile.fiori.common.StaticLayoutTextView

Class Overview

A wrapper of StaticLayout that can be used in place of TextView to improve performance. The benefits of using this view are:

  1. Avoid unnecessary overhead of TextView
  2. Measurement and layout can happen in background in advance
    1. See this instagram post

Summary

[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
StaticLayoutTextView(Context context)
Public Methods
int getBaseline()
int getGravity()
Returns the horizontal and vertical alignment of this StaticLayoutTextView.
int getLineHeight()
Gets the vertical distance between lines of text, in pixels.
void setGravity(int gravity)
Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the StaticLayoutTextView beyond what is required for the text itself.
void setStaticLayout(StaticLayout layout)
Sets the layout object.
Protected Methods
void onDraw(Canvas canvas)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
[Expand]
Inherited Methods
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public StaticLayoutTextView (Context context)

Public Methods

public int getBaseline ()

public int getGravity ()

Returns the horizontal and vertical alignment of this StaticLayoutTextView.

See Also

public int getLineHeight ()

Gets the vertical distance between lines of text, in pixels. Note that markup within the text can cause individual lines to be taller or shorter than this height, and the layout may contain additional first-or last-line padding.

Returns
  • The height of one standard line in pixels.

public void setGravity (int gravity)

Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the StaticLayoutTextView beyond what is required for the text itself.

See Also

public void setStaticLayout (StaticLayout layout)

Sets the layout object. No requestLayout() is called inside.

Parameters
layout the new layout object

Protected Methods

protected void onDraw (Canvas canvas)

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)