public class ScrollBarDrawable extends Drawable implements Drawable.Callback
Drawable.Callback, Drawable.ConstantState
Constructor and Description |
---|
ScrollBarDrawable() |
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas canvas)
Draw in its bounds (set via setBounds) respecting optional effects such
as alpha (set via setAlpha) and color filter (set via setColorFilter).
|
int |
getAlpha()
Gets the current alpha value for the drawable. 0 means fully transparent,
255 means fully opaque.
|
boolean |
getAlwaysDrawHorizontalTrack() |
boolean |
getAlwaysDrawVerticalTrack() |
ColorFilter |
getColorFilter()
Returns the current color filter, or
null if none set. |
int |
getOpacity()
Return the opacity/transparency of this Drawable.
|
int |
getSize(boolean vertical) |
void |
invalidateDrawable(Drawable who)
Called when the drawable needs to be redrawn.
|
boolean |
isStateful()
Indicates whether this drawable will change its appearance based on
state.
|
ScrollBarDrawable |
mutate()
Make this drawable mutable.
|
protected void |
onBoundsChange(Rect bounds)
Override this in your subclass to change appearance if you vary based on
the bounds.
|
protected boolean |
onStateChange(int[] state)
Override this in your subclass to change appearance if you recognize the
specified state.
|
void |
scheduleDrawable(Drawable who,
Runnable what,
long when)
A Drawable can call this to schedule the next frame of its
animation.
|
void |
setAlpha(int alpha)
Specify an alpha value for the drawable. 0 means fully transparent, and
255 means fully opaque.
|
void |
setAlwaysDrawHorizontalTrack(boolean alwaysDrawTrack)
Indicate whether the horizontal scrollbar track should always be drawn
regardless of the extent.
|
void |
setAlwaysDrawVerticalTrack(boolean alwaysDrawTrack)
Indicate whether the vertical scrollbar track should always be drawn
regardless of the extent.
|
void |
setColorFilter(ColorFilter colorFilter)
Specify an optional color filter for the drawable.
|
void |
setHorizontalThumbDrawable(Drawable thumb) |
void |
setHorizontalTrackDrawable(Drawable track) |
void |
setParameters(int range,
int offset,
int extent,
boolean vertical) |
void |
setVerticalThumbDrawable(Drawable thumb) |
void |
setVerticalTrackDrawable(Drawable track) |
String |
toString()
Returns a string representation of the object.
|
void |
unscheduleDrawable(Drawable who,
Runnable what)
A Drawable can call this to unschedule an action previously
scheduled with
Drawable.Callback.scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long) . |
applyTheme, canApplyTheme, clearColorFilter, clearMutated, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getChangingConfigurations, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isVisible, jumpToCurrentState, obtainAttributes, onLayoutDirectionChanged, onLevelChange, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, setVisible, setXfermode, unscheduleSelf
public void setAlwaysDrawHorizontalTrack(boolean alwaysDrawTrack)
alwaysDrawTrack
- Whether the track should always be drawngetAlwaysDrawHorizontalTrack()
public void setAlwaysDrawVerticalTrack(boolean alwaysDrawTrack)
alwaysDrawTrack
- Whether the track should always be drawngetAlwaysDrawVerticalTrack()
public boolean getAlwaysDrawVerticalTrack()
setAlwaysDrawVerticalTrack(boolean)
public boolean getAlwaysDrawHorizontalTrack()
setAlwaysDrawHorizontalTrack(boolean)
public void setParameters(int range, int offset, int extent, boolean vertical)
public void draw(Canvas canvas)
Drawable
protected void onBoundsChange(Rect bounds)
Drawable
onBoundsChange
in class Drawable
public boolean isStateful()
Drawable
isStateful
in class Drawable
Drawable.setState(int[])
protected boolean onStateChange(int[] state)
Drawable
onStateChange
in class Drawable
public void setVerticalThumbDrawable(Drawable thumb)
public void setVerticalTrackDrawable(Drawable track)
public void setHorizontalThumbDrawable(Drawable thumb)
public void setHorizontalTrackDrawable(Drawable track)
public int getSize(boolean vertical)
public ScrollBarDrawable mutate()
Drawable
mutate
in class Drawable
Drawable.ConstantState
,
Drawable.getConstantState()
public void setAlpha(int alpha)
Drawable
public int getAlpha()
Drawable
public void setColorFilter(ColorFilter colorFilter)
Drawable
If a Drawable has a ColorFilter, each output pixel of the Drawable's drawing contents will be modified by the color filter before it is blended onto the render target of a Canvas.
Pass null
to remove any existing color filter.
Note: Setting a non-null
color
filter disables tint
.
setColorFilter
in class Drawable
colorFilter
- The color filter to apply, or null
to remove the
existing color filterpublic ColorFilter getColorFilter()
Drawable
null
if none set.getColorFilter
in class Drawable
null
if none setpublic int getOpacity()
Drawable
PixelFormat
:
PixelFormat.UNKNOWN
,
PixelFormat.TRANSLUCENT
,
PixelFormat.TRANSPARENT
, or
PixelFormat.OPAQUE
.
An OPAQUE drawable is one that draws all all content within its bounds, completely covering anything behind the drawable. A TRANSPARENT drawable is one that draws nothing within its bounds, allowing everything behind it to show through. A TRANSLUCENT drawable is a drawable in any other state, where the drawable will draw some, but not all, of the content within its bounds and at least some content behind the drawable will be visible. If the visibility of the drawable's contents cannot be determined, the safest/best return value is TRANSLUCENT.
Generally a Drawable should be as conservative as possible with the
value it returns. For example, if it contains multiple child drawables
and only shows one of them at a time, if only one of the children is
TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be
returned. You can use the method Drawable.resolveOpacity(int, int)
to perform a
standard reduction of two opacities to the appropriate single output.
Note that the returned value does not necessarily take into account a
custom alpha or color filter that has been applied by the client through
the Drawable.setAlpha(int)
or Drawable.setColorFilter(android.graphics.ColorFilter)
methods. Some subclasses,
such as BitmapDrawable
, ColorDrawable
, and GradientDrawable
,
do account for the value of Drawable.setAlpha(int)
, but the general behavior is dependent
upon the implementation of the subclass.
getOpacity
in class Drawable
PixelFormat
public void invalidateDrawable(Drawable who)
Drawable.Callback
invalidateDrawable
in interface Drawable.Callback
who
- The drawable that is requesting the update.public void scheduleDrawable(Drawable who, Runnable what, long when)
Drawable.Callback
Handler.postAtTime(Runnable, Object, long)
with
the parameters (what, who, when) to perform the
scheduling.scheduleDrawable
in interface Drawable.Callback
who
- The drawable being scheduled.what
- The action to execute.when
- The time (in milliseconds) to run. The timebase is
SystemClock.uptimeMillis()
public void unscheduleDrawable(Drawable who, Runnable what)
Drawable.Callback
Drawable.Callback.scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long)
. An implementation can
generally simply call
Handler.removeCallbacks(Runnable, Object)
with
the parameters (what, who) to unschedule the drawable.unscheduleDrawable
in interface Drawable.Callback
who
- The drawable being unscheduled.what
- The action being unscheduled.public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())