public class

BubbleTextView

extends TextView
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ com.droidux.pack.commons.widget.editor.BubbleTextView

Class Overview

TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan because we want to make the bubble taller than the text and TextView's clip is too aggressive.

Summary

XML Attributes
Attribute Name Related Method Description
dux_bubbleColor setBubbleColor(int) Color of the bubble to be drawn behind the text. 
dux_drawBubble setDrawBubble(boolean) Controls whether to draw a bubble behind the text. 
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
BubbleTextView(Context context)
BubbleTextView(Context context, AttributeSet attrs)
BubbleTextView(Context context, AttributeSet attrs, int defStyle)
Public Methods
void draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
boolean getDrawBubble()
Returns whether a bubble behind the text should be drawn.
void setBubbleColor(int color)
Sets the color of the bubble.
void setDrawBubble(boolean draw)
Sets whether a bubble behind the text should be drawn.
Protected Methods
void drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
void onAttachedToWindow()
This is called when the view is attached to a window.
void onDetachedFromWindow()
This is called when the view is detached from a window.
boolean setFrame(int left, int top, int right, int bottom)
Assign a size and position to this view.
boolean verifyDrawable(Drawable who)
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.
[Expand]
Inherited Methods
From class android.widget.TextView
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.ViewTreeObserver.OnPreDrawListener
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

dux_bubbleColor

Since: API Level

Color of the bubble to be drawn behind the text.

May be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

Related Methods

dux_drawBubble

Since: API Level

Controls whether to draw a bubble behind the text. Default is true.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Related Methods

Public Constructors

public BubbleTextView (Context context)

Since: API Level 2.5

public BubbleTextView (Context context, AttributeSet attrs)

Since: API Level 2.5

public BubbleTextView (Context context, AttributeSet attrs, int defStyle)

Since: API Level 2.5

Public Methods

public void draw (Canvas canvas)

Since: API Level

Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, call the superclass version.

Parameters
canvas The Canvas to which the View is rendered.

public boolean getDrawBubble ()

Since: API Level 2.5

Returns whether a bubble behind the text should be drawn.

Related XML Attributes
Returns
  • True if the bubble should be drawn.

public void setBubbleColor (int color)

Since: API Level 2.5

Sets the color of the bubble.

Related XML Attributes
Parameters
color The bubble color.

public void setDrawBubble (boolean draw)

Since: API Level 2.5

Sets whether a bubble behind the text should be drawn.

Related XML Attributes
Parameters
draw If true, a bubble will be drawn.

Protected Methods

protected void drawableStateChanged ()

Since: API Level

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.

protected void onAttachedToWindow ()

Since: API Level

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

protected void onDetachedFromWindow ()

Since: API Level

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

protected boolean setFrame (int left, int top, int right, int bottom)

Since: API Level

Assign a size and position to this view. This is called from layout.

Parameters
left Left position, relative to parent
top Top position, relative to parent
right Right position, relative to parent
bottom Bottom position, relative to parent
Returns
  • true if the new size and position are different than the previous ones

protected boolean verifyDrawable (Drawable who)

Since: API Level

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.

Parameters
who The Drawable to verify. Return true if it is one you are displaying, else return the result of calling through to the super class.
Returns
  • boolean If true than the Drawable is being displayed in the view; else false and it is not allowed to animate.