-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback
,android.view.KeyEvent.Callback
,android.view.ViewTreeObserver.OnPreDrawListener
,android.view.accessibility.AccessibilityEventSource
,androidx.core.view.TintableBackgroundView
,androidx.core.widget.AutoSizeableTextView
,androidx.core.widget.TintableCompoundDrawablesView
public final class Label extends AppCompatTextView
A label of text attached to a view of the ExpandableFab widget.
Developer Notes:
Different views within the ExpandableFab widget can be labeled (like ExpandableFab and FabOption). Each labeled view will set their own default values for the properties of their specific label. Look at the documentation for the label property declared in each of theses classes to see what the default values of their labels are.
Implementation Notes:
Since the Kotlin 'internal' modifier translates to 'public' in Java, the JvmSynthetic annotation is used on those functions and properties to hide them from the published API for Java clients. A proper solution to this issue would be a package-private visibility modifier, but Kotlin has yet to implement it (https://youtrack.jetbrains.com/issue/KT-29227). Until then, the JvmSynthetic annotations should remain in order to present the proper published API to both Java & Kotlin clients.
-
-
Field Summary
Fields Modifier and Type Field Description private CharSequence
labelText
private Integer
labelTextColor
private Float
labelTextSize
private Typeface
labelFont
private Integer
labelBackgroundColor
private Integer
labelElevation
private LabelPosition
position
private Float
marginPx
private Float
translationXPx
private Long
visibleToHiddenAnimationDurationMs
private Long
hiddenToVisibleAnimationDurationMs
private Float
overshootTension
-
Method Summary
Modifier and Type Method Description final CharSequence
getLabelText()
The text of the Label. final Unit
setLabelText(CharSequence labelText)
final Integer
getLabelTextColor()
The color of the Label's text, as an integer in the form 0xAARRGGBB. final Unit
setLabelTextColor(Integer labelTextColor)
final Float
getLabelTextSize()
The size of the Label's text, as a float. final Unit
setLabelTextSize(Float labelTextSize)
final Typeface
getLabelFont()
The font of the Label's text. final Unit
setLabelFont(Typeface labelFont)
final Integer
getLabelBackgroundColor()
The color of the Label's background, as an integer in the form 0xAARRGGBB. final Unit
setLabelBackgroundColor(Integer labelBackgroundColor)
final Integer
getLabelElevation()
The elevation of the Label, in pixels as a positive float. final Unit
setLabelElevation(Integer labelElevation)
final LabelPosition
getPosition()
The Label's LabelPosition, in relation to the view it's attached to. final Unit
setPosition(LabelPosition position)
The Label's LabelPosition, in relation to the view it's attached to. final Float
getMarginPx()
The margin (in pixels as a positive float) between the Label and the view it is attached to. final Unit
setMarginPx(Float marginPx)
final Float
getTranslationXPx()
The distance (in pixels as a float) the Label will travel horizontally during animations. final Unit
setTranslationXPx(Float translationXPx)
The distance (in pixels as a float) the Label will travel horizontally during animations. final Long
getVisibleToHiddenAnimationDurationMs()
The duration (in milliseconds as a positive long) of the animations that the Label will play when going from a visible to hidden state. final Unit
setVisibleToHiddenAnimationDurationMs(Long visibleToHiddenAnimationDurationMs)
final Long
getHiddenToVisibleAnimationDurationMs()
The duration (in milliseconds as a positive long) of the animations that the Label will play when going from a hidden to visible state. final Unit
setHiddenToVisibleAnimationDurationMs(Long hiddenToVisibleAnimationDurationMs)
final Float
getOvershootTension()
The tension (as a positive float) in an OvershootInterpolator applied on the Label when it is being shown from a hidden state. final Unit
setOvershootTension(Float overshootTension)
Boolean
onTouchEvent(MotionEvent event)
Scales the Label down when pressed, and back up when released. -
-
Constructor Detail
-
Label
Label(Context context)
Used to create a Label programmatically.
-
-
Method Detail
-
getLabelText
final CharSequence getLabelText()
The text of the Label. Can be set to null to hide the label. Usage of this property is preferred over the inherited set/getText methods.
-
setLabelText
final Unit setLabelText(CharSequence labelText)
-
getLabelTextColor
final Integer getLabelTextColor()
The color of the Label's text, as an integer in the form 0xAARRGGBB.
If using an XML resource color value, retrieve it in the correct form by calling: ContextCompat.getColor(context, R.color.name_of_color_resource).
Usage of this property is preferred over the inherited setTextColor method variations.
-
setLabelTextColor
final Unit setLabelTextColor(Integer labelTextColor)
-
getLabelTextSize
final Float getLabelTextSize()
The size of the Label's text, as a float. Retrieve this value in the correct form from your dimens.xml file using: resources.getDimension(R.dimen.name_of_text_size). Text sizes should use sp as the unit. Usage of this property is preferred over the inherited set/getTextSize methods.
-
setLabelTextSize
final Unit setLabelTextSize(Float labelTextSize)
-
getLabelFont
final Typeface getLabelFont()
The font of the Label's text. Retrieve this value in the correct form from your resources using: ResourcesCompat.getFont(context, R.font.name_of_font). Usage of this property is preferred over the inherited set/getTypeface methods.
-
setLabelFont
final Unit setLabelFont(Typeface labelFont)
-
getLabelBackgroundColor
final Integer getLabelBackgroundColor()
The color of the Label's background, as an integer in the form 0xAARRGGBB.
If using an XML resource color value, retrieve it in the correct form by calling: ContextCompat.getColor(context, R.color.name_of_color_resource).
Usage of this property is preferred over the inherited setBackgroundColor method.
-
setLabelBackgroundColor
final Unit setLabelBackgroundColor(Integer labelBackgroundColor)
-
getLabelElevation
final Integer getLabelElevation()
The elevation of the Label, in pixels as a positive float. Retrieve this value in the correct form from your dimens.xml file using: resources.getDimensionPixelSize(R.dimen.name_of_elevation_size). Usage of this property is preferred over the inherited set/getElevation methods.
-
setLabelElevation
final Unit setLabelElevation(Integer labelElevation)
-
getPosition
final LabelPosition getPosition()
The Label's LabelPosition, in relation to the view it's attached to.
-
setPosition
final Unit setPosition(LabelPosition position)
The Label's LabelPosition, in relation to the view it's attached to.
-
getMarginPx
final Float getMarginPx()
The margin (in pixels as a positive float) between the Label and the view it is attached to. Negative values are not allowed since clients should likely be changing the Label's position if they wanted to move the Label to the opposite side of the view it's attached to.
-
setMarginPx
final Unit setMarginPx(Float marginPx)
-
getTranslationXPx
final Float getTranslationXPx()
The distance (in pixels as a float) the Label will travel horizontally during animations. A negative value will make the Label travel to the left, while a positive value will make it travel to the right. See its use in visibleToHiddenAnimations and hiddenToVisibleAnimations.
-
setTranslationXPx
final Unit setTranslationXPx(Float translationXPx)
The distance (in pixels as a float) the Label will travel horizontally during animations. A negative value will make the Label travel to the left, while a positive value will make it travel to the right. See its use in visibleToHiddenAnimations and hiddenToVisibleAnimations.
-
getVisibleToHiddenAnimationDurationMs
final Long getVisibleToHiddenAnimationDurationMs()
The duration (in milliseconds as a positive long) of the animations that the Label will play when going from a visible to hidden state. Set to 0L if you don't want animations played.
-
setVisibleToHiddenAnimationDurationMs
final Unit setVisibleToHiddenAnimationDurationMs(Long visibleToHiddenAnimationDurationMs)
-
getHiddenToVisibleAnimationDurationMs
final Long getHiddenToVisibleAnimationDurationMs()
The duration (in milliseconds as a positive long) of the animations that the Label will play when going from a hidden to visible state. Set to 0L if you don't want animations played.
-
setHiddenToVisibleAnimationDurationMs
final Unit setHiddenToVisibleAnimationDurationMs(Long hiddenToVisibleAnimationDurationMs)
-
getOvershootTension
final Float getOvershootTension()
The tension (as a positive float) in an OvershootInterpolator applied on the Label when it is being shown from a hidden state. Larger values will exaggerate the effect more.
The OvershootInterpolator allows us to have an animation where the Label will fling past its marginPx when initially appearing, before smoothly coming back toward its marginPx value.
-
setOvershootTension
final Unit setOvershootTension(Float overshootTension)
-
onTouchEvent
Boolean onTouchEvent(MotionEvent event)
Scales the Label down when pressed, and back up when released. Gives the user some visual feedback to show that the Label was pressed.
-
-
-
-