TooltipDrawable
public
class
TooltipDrawable
extends MaterialShapeDrawable
java.lang.Object | |||
↳ | android.graphics.drawable.Drawable | ||
↳ | com.google.android.material.shape.MaterialShapeDrawable | ||
↳ | com.google.android.material.tooltip.TooltipDrawable |
A Tooltip that supports shape theming and draws a pointer on the bottom in the center of the supplied bounds. Additional margin can be applied which will prevent the main bubble of the Tooltip from being drawn too close to the edge of the window.
Note: setRelativeToView(View)
should be called so TooltipDrawable
can
calculate where it is being drawn within the visible display.
Summary
XML attributes | |
---|---|
Tooltip_android_layout_margin |
|
Tooltip_android_minHeight |
|
Tooltip_android_minWidth |
|
Tooltip_android_padding |
|
Tooltip_android_text |
|
Tooltip_android_textAppearance |
Inherited constants |
---|
Public methods | |
---|---|
static
TooltipDrawable
|
create(Context context)
|
static
TooltipDrawable
|
createFromAttributes(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Returns a TooltipDrawable from the given attributes. |
static
TooltipDrawable
|
createFromAttributes(Context context, AttributeSet attrs)
Returns a TooltipDrawable from the given attributes. |
void
|
detachView(View view)
Should be called when the view is detached from the screen. |
void
|
draw(Canvas canvas)
|
int
|
getIntrinsicHeight()
|
int
|
getIntrinsicWidth()
|
int
|
getLayoutMargin()
Returns the margin around the TooltipDrawable. |
int
|
getMinHeight()
Returns the minimum height of TooltipDrawable in terms of pixels. |
int
|
getMinWidth()
Returns the minimum width of TooltipDrawable in terms of pixels. |
CharSequence
|
getText()
Return the text that TooltipDrawable is displaying. |
TextAppearance
|
getTextAppearance()
Returns the TextAppearance used by this tooltip. |
int
|
getTextPadding()
Returns the padding between the text of TooltipDrawable and the sides in terms of pixels. |
boolean
|
onStateChange(int[] state)
|
void
|
onTextSizeChange()
|
void
|
setLayoutMargin(int layoutMargin)
Sets the margin around the TooltipDrawable to be |
void
|
setMinHeight(int minHeight)
Sets the height of the TooltipDrawable to be at least |
void
|
setMinWidth(int minWidth)
Sets the width of the TooltipDrawable to be at least |
void
|
setRelativeToView(View view)
Should be called to allow this drawable to calculate its position within the current display frame. |
void
|
setRevealFraction(float fraction)
A fraction that controls the scale of the tooltip and the opacity of its text. |
void
|
setText(CharSequence text)
Sets the text to be displayed. |
void
|
setTextAppearance(TextAppearance textAppearance)
Sets this tooltip's text appearance. |
void
|
setTextAppearanceResource(int id)
Sets this tooltip's text appearance using a resource id. |
void
|
setTextPadding(int padding)
Sets the padding between the text of the TooltipDrawable and the sides to be |
void
|
setTextResource(int id)
Sets the text to be displayed using a string resource identifier. |
Protected methods | |
---|---|
void
|
onBoundsChange(Rect bounds)
|
Inherited methods | |
---|---|
XML attributes
Tooltip_android_layout_margin
Related methods:
Tooltip_android_minHeight
Related methods:
Tooltip_android_minWidth
Related methods:
Tooltip_android_padding
Related methods:
Tooltip_android_text
Related methods:
Tooltip_android_textAppearance
Related methods:
Public methods
create
public static TooltipDrawable create (Context context)
Parameters | |
---|---|
context |
Context |
Returns | |
---|---|
TooltipDrawable |
createFromAttributes
public static TooltipDrawable createFromAttributes (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Returns a TooltipDrawable from the given attributes.
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
defStyleRes |
int |
Returns | |
---|---|
TooltipDrawable |
createFromAttributes
public static TooltipDrawable createFromAttributes (Context context, AttributeSet attrs)
Returns a TooltipDrawable from the given attributes.
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
Returns | |
---|---|
TooltipDrawable |
detachView
public void detachView (View view)
Should be called when the view is detached from the screen.
Parameters | |
---|---|
view |
View |
See also:
draw
public void draw (Canvas canvas)
Parameters | |
---|---|
canvas |
Canvas |
getIntrinsicHeight
public int getIntrinsicHeight ()
Returns | |
---|---|
int |
getIntrinsicWidth
public int getIntrinsicWidth ()
Returns | |
---|---|
int |
getLayoutMargin
public int getLayoutMargin ()
Returns the margin around the TooltipDrawable.
Related XML Attributes:
Returns | |
---|---|
int |
See also:
getMinHeight
public int getMinHeight ()
Returns the minimum height of TooltipDrawable in terms of pixels.
Related XML Attributes:
Returns | |
---|---|
int |
See also:
getMinWidth
public int getMinWidth ()
Returns the minimum width of TooltipDrawable in terms of pixels.
Related XML Attributes:
Returns | |
---|---|
int |
See also:
getText
public CharSequence getText ()
Return the text that TooltipDrawable is displaying.
Related XML Attributes:
Returns | |
---|---|
CharSequence |
getTextAppearance
public TextAppearance getTextAppearance ()
Returns the TextAppearance used by this tooltip.
Related XML Attributes:
Returns | |
---|---|
TextAppearance |
getTextPadding
public int getTextPadding ()
Returns the padding between the text of TooltipDrawable and the sides in terms of pixels.
Related XML Attributes:
Returns | |
---|---|
int |
See also:
onStateChange
public boolean onStateChange (int[] state)
Parameters | |
---|---|
state |
int |
Returns | |
---|---|
boolean |
onTextSizeChange
public void onTextSizeChange ()
setLayoutMargin
public void setLayoutMargin (int layoutMargin)
Sets the margin around the TooltipDrawable to be margin
.
Related XML Attributes:
Parameters | |
---|---|
layoutMargin |
int : the margin to use around the TooltipDrawable |
See also:
setMinHeight
public void setMinHeight (int minHeight)
Sets the height of the TooltipDrawable to be at least minHeight
wide.
Related XML Attributes:
Parameters | |
---|---|
minHeight |
int : the minimum height of TooltipDrawable in terms of pixels |
See also:
setMinWidth
public void setMinWidth (int minWidth)
Sets the width of the TooltipDrawable to be at least minWidth
wide.
Related XML Attributes:
Parameters | |
---|---|
minWidth |
int : the minimum width of TooltipDrawable in terms of pixels |
See also:
setRelativeToView
public void setRelativeToView (View view)
Should be called to allow this drawable to calculate its position within the current display frame. This allows it to apply to specified window padding.
Parameters | |
---|---|
view |
View |
See also:
setRevealFraction
public void setRevealFraction (float fraction)
A fraction that controls the scale of the tooltip and the opacity of its text.
When fraction is 0.0, the tooltip will be completely hidden, as fraction approaches 1.0, the tooltip will scale up from its pointer and animate in its text.
This method is typically called from within an animator's update callback. The animator in this case is what is driving the animation while this method handles configuring the tooltip's appearance at each frame in the animation.
Parameters | |
---|---|
fraction |
float : A value between 0.0 and 1.0 that defines how "shown" the tooltip will be.
|
setText
public void setText (CharSequence text)
Sets the text to be displayed.
Related XML Attributes:
Parameters | |
---|---|
text |
CharSequence : text to be displayed |
See also:
setTextAppearance
public void setTextAppearance (TextAppearance textAppearance)
Sets this tooltip's text appearance.
Related XML Attributes:
Parameters | |
---|---|
textAppearance |
TextAppearance : This tooltip's text appearance. |
setTextAppearanceResource
public void setTextAppearanceResource (int id)
Sets this tooltip's text appearance using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this tooltip's text appearance. |
setTextPadding
public void setTextPadding (int padding)
Sets the padding between the text of the TooltipDrawable and the sides to be padding
.
Related XML Attributes:
Parameters | |
---|---|
padding |
int : the padding to use around the text |
See also:
setTextResource
public void setTextResource (int id)
Sets the text to be displayed using a string resource identifier.
Related XML Attributes:
Parameters | |
---|---|
id |
int : the resource identifier of the string resource to be displayed |
See also:
Protected methods
onBoundsChange
protected void onBoundsChange (Rect bounds)
Parameters | |
---|---|
bounds |
Rect |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-05-11 UTC.